As long as you manage a website, the term server migration would bang you at least once. Well, this arises due to a number of factors such as moving to a powerful server in order to have better resources to process data, change in environment like updating to a newer version of your program or web server for better results or change of service provider. The term server migration may hit you in a great deal, because you fear about lose of data, unstable websites or down-times. This article focuses on how to achieve webserver migration with zero down time without any data loss. Lets start!
1. Prepare Your DNS
When you move your site(s) to a new server, you will likely get new IP addresses. The problem is that DNS servers cache domain name queries for as long as possible to provide the fastest response. Because of these DNS caching, once you change your IP, it can take up to three days before the changes propagate throughout the Internet. To keep this from happening, your first step in preparing for the migration is to change your DNS record TTL (Time To Live). This value designates how long your DNS entries should be cached. So the first thing you need to do before migrating is to lower the TTL to reasonable levels.
2. Set up Your New Server
Make sure your new server has the correct operating system installed and ready and that all hardware meets your applications specifications. Also setup the new IP addresses.
3. Tune Your Server
Check your file system and make sure your partitions are set up as you need them. Set up RAID if required. This is also the perfect time to implement any security practices within the OS and firewall (if installed). Its important to complete these steps before you get too far because they are much easier to do without content on the server.
4. Install Base Applications
Once you have installed the OS and setup the file system, you are ready to install the base applications, like the Web server, e-mail server, database server, PHP, etc.. Also verify the services are running fine on the new server.
5. Begin Data Migration
Once the base applications are installed, you are ready to do the initial migration of your application data. This includes the database data, your application code files, mail server account configuration, logs, file caches, etc..
6. Bring your new server to life.
Once the data is migrated the server is configured to work everything correctly, you should change your sites domain DNS records to point to the new server address.
If you are using any Control Panels like cPanel, Plesk, etc., it rather easy to move data/accounts between servers as each control panel will give you option to move accounts.
cPanel Server to cPanel server migration
To migrate from one cPanel server to another, please do this:
1. Log into WHM as root on the new cPanel server
2. Click “Copy multiple accounts/packages from another server”
3. Fill in the required information like source server details and click “Fetch Account List”
You will then be given the option to choose which accounts and packages to transfer.
cPanel also does support migrating accounts from different control panel other than cPanel itself.
Server without a control panel
Rsync is a simple and very powerful tools which can be used to transfer files between servers efficiently.
First copy all the configurations files for the services like Web server, Email server, etc. Then transfer the account data from old server.
#rsync -avz -e ssh /home root@remoteserverip:/home
-v: verbose, will tell you what file its on, how many left to check, etc.
-a: archive, will set most of the preferable options.
–progress: gives you per-file data transfer rates, and spinning progress bars if you’re into that sort of thing.
-z, –compress file data during the transfer
Please note that we do not need to copy the server related files. We can exclude from the rsync list. The most important excludes are the ones that reference hardware and system files that keep track of the server’s status while it’s running. That’s why directories like /boot, /proc, and /dev are essential excludes. The destination server should already have those directories and config files in place and they shouldn’t be overwritten.
#rsync -avz -e ssh –exclude-from=”/home/exclude.txt” /home root@remoteserverip:/home
Finalizing the migration
Doing one pass got the more static files over to the new server. That’s good, but that may not be everything you needed to copy. An active database or a directory where a lot of files get created and deleted may have been copied but changed already. Or, more practically, they may have been in your exclude file.
To get those last files you’ll want to bring the services that use them down. That way you know the entire file will be migrated with no changes made after your last sync.
Edit your exclude file to remove references to the busy files you were holding off on then run the rsync command again.
If you require help, contact SupportPRO Server Admin