Previous class
Magento Migration
Migration
2.1 Backup the old server
On the old server, create a backup of the Magento directory and the database.
For the Magento directory, use tar
:
bash
cd /var/www/
tar czf magento.tar.gz magento/
For the database, use mysqldump
:
bash
mysqldump -u magento -p magento > magento.sql
2.2 Transfer the backups
Transfer the backups to the new server using scp
or rsync
. Make sure you replace your_username
and your_server_ip
with your actual username and the IP address of your new server:
bash
scp magento.tar.gz your_username@your_server_ip:/path/to/directory
scp magento.sql your_username@your_server_ip:/path/to/directory
2.3 Restore the backups
On the new server, restore the backups.
Extract the Magento directory:
bash
cd /var/www/
tar xzf /path/to/magento.tar.gz
Import the database:
bash
mariadb -u magento -p magento < /path/to/magento.sql
Update the app/etc/env.php
file in the Magento directory with the correct database configuration.
After restoring, you might also need to clear the cache and reindex:
bash
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
You should now have a working copy of your Magento 2 site on your new server.
Next class