Magento Server Migration: Migrate Magento Store to a New Server. In this guide, we introduce Magento, talk about server migration then explain how to migrate the Magento store to a new server.
Moving big volumes of data from one server to another might be scary since data is valuable. For reasons of safety, while upgrading or replacing hardware, or for other reasons, data may be transferred between servers. Read on for in depth information on Magento server migration and its many facets.
Magento is an extensible open source eCommerce platform with various available extensions, including plugins, themes, and tools. It’s ideal for micro and medium sized enterprises.
It provides a comprehensive set of tools for building an online store. Since its first release in 2008, Magento has undergone several iterations and enhancements. Using a tool or sophisticated Server transferring software, data, programs, and even user data may be moved from one server to another. This procedure is known as Server Migration.
Server professionals frequently execute this operation. However, anybody with sufficient computer abilities may migrate their data across servers. Data accessibility may be interrupted during transfer.
Transferring your data from one host’s server to another host’s server is what is meant by the term “migrating hosts.” If you are switching servers, you are not doing so without a host. There may be one or two hosts engaged in this.
When moving to a different server from the same host, both hosts are considered “migrating hosts.” If, on the other hand, you want to transfer files to a new server with a new host, the host being migrated is the one to which the files are ultimately moved.
How Long Does a Server Migration Take?
Factors such as server and data sizes, network connections, site activity, and time of day all affect how long it takes to complete a server migration.
Depending on the amount of data being transferred and whether or not the migration is being performed during peak hours, relocating a server may take anywhere from 30 minutes to three hours.
The longer it takes for the server transfer to finish, the more data is being sent and received, which consumes more bandwidth.
Magento Server Migration: Migrate Magento Store to a New Server
In this section, we guide you how to migrate Magento to a new server.
Step 1: Create a Backup of the Magento Database
The database is an important aspect of the Magento store. The Magento Database contains your store information, such as store settings, orders, customers, products, etc. So you need to backup the Magento database first. Use the mysqldump command-line utility to backup the Magento database.
First, connect to your Magento server via SSH. Then, switch the directory to the Magento store.
cd /var/www/html/magento
Next, verify all your Magento files using the following command.
ls
You see all the files and directories on the following screen.
Now, run the mysqldump command to create a full backup of Magento.
The Magento filesystem contains your store product media, extension code, and the Magento codebase. So you will also need to backup a Magento filesystem to your system.
First, navigate to the Magento directory using the following command.
cd /var/www/html/magento
Next, run the following command to create a Tar archive of your Magento filesystem.
tar -czf ./magento-files.tar.gz --exclude=var/cache --exclude=var/full_page_cache --exclude=var/log --exclude=var/report --exclude=var/session .
Then, you will need to put your store in maintenance mode to prevent data inconsistencies during the file migration. You can run the following command to enable maintenance mode.
php bin/magento maintenance:enable
Step 3 - Prepare the Destination Server
After backing up a Magento filesystem and database, you need to prepare a new server to migrate all data from the older server to the newer one. Keep in mind the following when you prepare a new server.
Install a LAMP stack with all necessary PHP extensions.
Use the same database credentials on both the origin and the destination server.
The Magento filesystem owner should be the same on both servers.
After preparing a new server, it’s time to migrate a filesystem and database to a new server. First, create a Magento directory inside the web root directory of your destination server.
Before accessing the new Magento store do it via a web browser. Update the DNS records of your domain and point it to the new server IP address. Wait for some time to propagate the DNS record.
After the propagating the DNS changes, install cron to allow Magento to perform vital background tasks.
php bin/magento cron:install
Finally, switch your Magento store into production mode using the following command.
php bin/magento deploy:mode:set production
You can now access your newly migrated Magento store via a web browser using your domain name.
Magento Server Migration: Migrate Magento Store to a New Server Conclusion
In this post, we have created a database and filesystem backup on the origin Magento server. Then, we prepared a new Magento server and imported both backup files to the new server. We then changed the DNS setting pointing to the new server IP and verified the migration via a web browser.
Since data is so crucial in modern IT, no information must be lost during the server relocation. Prioritizing data based on its value is a crucial step toward a successful transfer.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.