Before The Move
Before we even think about moving accounts we need to think about a few other things that need sorting first.
Purchasing A New Server
First things first, if you haven’t already you need to have your new server set-up, have cPanel installed, installed your Firewall and then leave it… just leave it for 4-5 days. This is so you can make sure a. the server is stable and b. the new companies network is stable. The last thing you need is to move all your accounts over and find out the new network is rubbish and your server crashes every five minuets.
Update DNS TTL (Time to Live)
This step has to be done 48-72 hours prior to migration. Changing the TTL (Time To Live) from 14400 (4 hours) to 300 (5 minutes) means that as soon as we make a change to a DNS zone, it will take affect everywhere within 5 minutes as opposed to 4 hours.
To do so you need to run the following commands in your SSH console.
mkdir -p /backup/named-baka ; cp /var/named/*.db /backup/named-baka perl -pi -e 's/\$TTL 300/\$TTL 14400/g' /var/named/*.db
Once you have done this its just a waiting game… Leave it for a while just to make sure its populated though out the world (24 hours).
Once a day has gone by its d-day… The day of migration. First we need to stop all services on the old server other than Apache and MySQL (to avoid loosing any emails or files people upload) You can do this by running the following commands in SSH
/etc/init.d/cpanel stop /etc/init.d/exim stop /etc/init.d/pure-ftpd stop;/scripts/ckillall -9 pure-ftpd;/scripts/ckillall -9 pure-authd /etc/init.d/proftpd stop
Let The Copying Begin
After that login to WHM on the new server as root then do the following steps:
- Click on “Copy Multiple Accounts/Packages From Another Server” (under Transfers)
- Fill out the old server data
- Select the accounts to transfer
- Start the transfer process (this can take some time)
Once the transfer has finished make sure everything is copied across ok and nothing is missing, if you run into any trouble comment below and I will try to help. Once you are happy everything is there SSH into the old server and run the following commands:
mkdir -p /backup/named-bak ; cp /var/named/*.db /backup/named-bak sed -i 's/[OLD_SERVER_IP]/[NEW_SERVER_IP]/g' *.db /etc/init.d/named restart
The above commands first make a backup of your DNS databases for each account. Then goes through all of the accounts and updates the DNS records from the old IP to the new IP forcing the DNS servers to send all traffic to the new server! (note this can take anything from 15 – 60 minuets to take effect).
For sites not on a shared IP you will need to edit these DNS records separately to reflect the new IP. Well Done! – All the websites are functioning on the new server, now transfer your Nameservers! Don’t forget to give it 48 hours for the DNS to settle down. DNS can be a pain and take longer to update than other peoples DNS its all different. Once you have waited 48 hours you can shutdown your old server and cancel your account with that host you couldn’t wait to leave!
Note: If you have resellers, we have to copy all the files in /var/cpanel that reference resellers and anything ending in .accts to the new server.
Photo By: Getbutterfly