DEV Community

mark vachi
mark vachi

Posted on

Note: Migrating a Database and Laravel Storage to a New Machine

Specification

192.0.0.1 is the old machine, and 192.0.0.2 is the new machine. Both machines are Ubuntu servers running MySQL for the database and Laravel for the web app on Vesta control panel.

STEP 1

Export the database from the old machine:

$ mysqldump admin_database > admin_database.sql
Enter fullscreen mode Exit fullscreen mode

STEP 2

Compress the storage directory (which includes several subdirectories) on the old machine:

$ tar -czvf storge.tar.gz storage/app storage/excel/exports public/uploads
Enter fullscreen mode Exit fullscreen mode

STEP 3

Transfer the files to the new machine via FTP protocol using curl, which allows you to see the transfer progress:

$ curl -T admin_database.sql ftp://192.0.0.2 --user <username>:<password>

$ curl -T storge.tar.gz ftp://192.0.0.2 --user <username>:<password>
Enter fullscreen mode Exit fullscreen mode

Note: FTP needs to be installed and the FTP port needs to be opened on the new machine. Refer to this guide on how to install-ftp-server-on-ubuntu.

STEP 4

Import the database to the new machine:

$ mv storge.tar.gz /home/admin/web/domain_name/public_html
$ cd /home/admin/web/domain_name/public_html
$ tar -xvf storge.tar.gz
Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay