Moving all the accounts between two Servers that host the same control panel is usually not a very difficult process.
You need to move all domains from the present server to the new server. At the same time, you need the whole move done perfectly and with zero downtime for all domains. In addition, you need to move even your nameservers between two different datacenters. Its pretty complicated.
Migration implementation
1. The nameservers and the domains TTL (Time To Live) needs to be reduced to, say between 30 minutes to 1 hour. This change has to be effected at least one week before the IP changes, as it needs time to propogate to the various ISP’s all around the world. This ensures that the fresh zone files are loaded all around the world faster and that they access the old server for a shorter duration.
2. Accounts need to be moved to the new server. All information just prior to the IP changes of the client should not be lost and hence “rsync” is the needed just prior to the move.
3. The change over should have minimum impact in terms of site accesses becoming slow or mails being lost.
4. The new server needs to be setup and properly configured prior to the move and all necessary softwares need to be installed.
5. A study of the top 10 domains that use maximum softwares/resources on the server needs to be done. This way, once the move is done, they are checked to first ensure everything is working like ins the old server.
Nameserver TTL
1. Login to the cpanel WHM,
http://oldserver.com:2086
Username : root
Password : “your password”
1. Then Go to the following link
Main –> Server Configuration –> Basic cPanel/WHM Setup
1. Set Domain Time to Live & Nameserver Time to Live to 3600 seconds and save changes.
Moving Accounts
1. Login to the WHM of the new server and go to
Main –> Transfers –> Copy multiple accounts from another server
1. Enter the old server’s IP address, enter the password and click on “grab account list”
2. This will give you a list of all the accounts on the old server. Select the accounts you need copied over and once completed, initiate the transfer.
3. Once this transfer is completed, (it may take anywhere between 2-12 hours depending on connection speeds, server utilization, size of accounts being moved) only then should you close the window. Any connection breakup would mean you would need to terminate the copy on the new server and reinitiate the transfer again from the one where the connection broke.
4. You will get a status report on all account moves that were successful. Accounts that have a “-” in their username is not accepted in the new cPanel taxonomy, so you would need to manually make changes and copy those accounts over on to the new server.
Rsync
Once the account moves are done, the next thing would be that till the ip changes, nameserver changes are done for the accesses to be directed to the accounts on the new server, we would need to ensure that they are synchronized and no data is lost.
To rsync, follow these steps:
a) Setup ssh-key
b) rsync the folders /home , /var/cpanel , /var/lib/mysql , /usr/local/cpanel/3rdparty/mailman , /usr/local/cpanel/base/frontend , /etc/valiases , /etc/vdomainaliases , /etc/vfilters using the commands
for user in `cat /home/tomove`; do rsync -avuz -e ssh root@OLDSERVERIP:/home/$user/ /home/$user; done
rsync -avuz -e ssh root@OLDserverIP:/var/cpanel /var/cpanel
rsync -avuz -e ssh root@OLDserverIP:/var/lib/mysql /var/lib/mysql
rsync -avuz -e ssh root@OLDserverIP:/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty/mailman
rsync -avuz -e ssh root@OLDserverIP:/usr/local/cpanel/base/frontend /usr/local/cpanel/base/frontend
rsync -avuz -e ssh root@OLDserverIP:/etc/valiases /etc/valiases
rsync -avuz -e ssh root@OLDserverIP:/etc/vdomainaliases /etc/vdomainaliases
rsync -avuz -e ssh root@OLDserverIP:/etc/vfilters /etc/vfilters
Fixing Databases
Once rsync is completed, you need to repair the mysql databases since they get corrupted.
By running /scripts/fixmysql on the new server and verifying if the databases are showing to be ok, you can ensure that there is no corruption in databases. Just run the following commands after going to /var/lib/mysql on the new server
/scripts/fixmysql;/usr/bin/mysql_fix_privilege_tables;/usr/bin/mysqlcheck -A –auto-repair;myisamchk -r -e ./*
Setting up Cron
You can setup Cron scheduler to repeat the rsync every couple of hours till the IP’s on the old server are changed to that of new servers. This ensures minimum loss of data.
Changing IP on the OLD Server
Initially when you move accounts to the new server, you need to ensure they all use the same shared IP and we need to keep a list of the accounts that need unique IP. Once the account moves are completed, do the following steps on the old server:
1. Change the IP the zone files of the DNS on old server to new server.
cd /var/named
perl -pi.bak -e “s/[oldip]/[newip]/g” *.db
1. Next, do these steps:
mv /etc/secondarymx /etc/secondarymx.orig
mv /etc/localdomains /etc/secondarymx
mv /etc/secondarymx.orig /etc/localdomains
This ensures that mails sent locally within the server as well as using forms, also go to the new server instead of being sent to the local mailboxes.
In 24 hours time, if everything is working fine and the accesses are moving to the new server, set the TTL and nameserver TTL on the new server to 14400 and you can shutdown the old server. Also you can change the IP’s of dedicated IP clients to unique IP’s and everything should work fine.