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

Top comments (0)