Home / Magento Tutorials / Magento migration: How to move Magento store to the new server

Magento migration: How to move Magento store to the new server

move-your-magento store-to-a-new-server

This article helps you ease this migration by some useful steps and guides you to avoid the most common mistakes made while Magento migration.

1. Checkout for the Minimal Magento Requirements

The first thing you think before migration is that the server should meet the minimum requirements of your Magento store. If required you’ll have to set up PHP or install the missing extensions. Also, make sure you have enough disk space to accommodate the store as well as some extra space.

2. Be on A Safer Side – Take Store’s Backup and Copy

While making swift decisions, always remember The Rule: “Always Test Your Changes”.

Once you are sure that the new server meets all the requirements and the shop is working well, you’re ready and all you need is to sync data before switching on!

Now, Create a website and a database for your Magento Store.

Your store is really very valuable, so before transferring to a new server remember to take up a backup and copy of all your data. To compress the size of your backup files, exclude var/cache, var/full_page_cache, var/log, var/report, var/session.

cd /home/mageold/public_html
tar -czf ~/magento-files.tar.gz --exclude=var/cache --exclude=var/full_page_cache --exclude=var/log --exclude=var/report --exclude=var/session .
mysqldump -h localhost -u mageold_magento -p mageold_magento | gzip > ~/magento-db.sql.gz

I recommend SCP – the most convenient way to transfer the backup files to a new server.

scp ~/magento-file.tar.gz ~/magento -db.sql.gz magennew@newhost

Now it’s time to put up the backup files on the new server.

tar -xzf ~/magento-files.tar.gz -C /home/magenew/public_html
gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u magenew_magento -p magenew_magento

3. Install the Recovery Files to a new server

The process of installing the backup files is through editing app/etc/local.xml and adding the new database settings to it. For changing the Access Permissions, there are two options:

(i) The web server runs the scripts on behalf of the user who owns the files. You may need to set the permission like this

find /home/magenew/public_html -type f -print0 | xargs -r0 chmod 640
find /home/magenew/public_html -type d -print0 | xargs -r0 chmod 750

(ii) The web server runs scripts on behalf of some other user which allows the webserver save the files which do not belong to it, giving up a different value like this

find /home/magenew/public_html -type f -print0 | xargs -r0 chmod 644
find /home/magenew/public_html -type d -print0 | xargs -r0 chmod 755
chmod -R a+w /home/magenew/public_html/{app/etc,media,var,includes}

4. Testing Your Newly Moved Store Is Necessary

Now you’re all done with the migration but your domain is still indicating the old server. So you’ll have to add this line to the host file:

/etc/hosts – for Unix Operating System
C:\Windows\System32\Drivers\etc\hosts – for Window based Administration System

Now, it’s time for Testing. Be careful and check out the full flow and functioning of your newly migrated store. This is a crucial step, so for better results, the test under the user perspective whether the process of shopping is running smoothly and if you find errors – fix them, and you’re done with the testing part.

5. Synchronize The Data

If everything works well, it’s time to synchronize data. There are two crucial points to complete the process of migrating your Magento store to a new server:

  • Switch Off the shop on your old server while you sync your data.

To switch off the old server, turn Cron off and enable maintenance mode at

touch /home/mageold/public_html/maintenance.flag

Now, you can sync the data and speed up the process, use rsync.

rsync -avz --delete -exclude=var/cache --exclude=var/full_page_cache --exclude=var/log --exclude=var/report --exclude=var/session --exclude=app/etc/local.xml /home/mageold/public_html/ magenew@newhost:/home/magenew/public_html/
mysqldump --add-drop-table -h localhost -u mageold_magento -p mageold_magento | gzip > ~/magento-db.sql.gz
scp ~/magento-db.sql.gz magenew@newhost:

Now you can upload the database to your new server.

gzip -dc ~/magento-db.sql.gz | mysql -h localhost -u magenew_magento -p magenew_magento

Access permissions may be changed during synchronization, so ensure to check or restore them.

Remember to clear Magento cache:

rm -fr /home/magenew/public_html/var/{cache,full_page_cache,log,report,session}

6. Final Step – Turn On The New Server

Now you’re almost done! Turn on the Cron tasks for the new server and change the DNS settings so that the domain points to the new server. And as TTL time expires, the traffic will be directed to the new server.

Now you can turn off the old server. Please remember to have a backup copy file so that you can rewind in case of any unexpected circumstances.

So Magento migration is finish. Thank you for Reading! If you have any questions, please contact us.

Source: brainsins.com

About admin

Check Also

PHP 7 and Magento 2 a quick overview

Quick Overview: PHP 7 and Magento

How time flies! It was eleven years of waiting from the release of PHP 5.0. …