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
cPanel 11.36 is shipped with perl 5.14.3. that might make some problems for your cpan. Some of you might face an error while trying to run easyapache which says:
!! Failed to install CPAN Perl module(s) Crypt::PasswdMD5 !!
Well to fix this issue just run following command to install Crypt::PasswdMD5
# /usr/local/cpanel/bin/cpanm -n Digest::SHA1 Crypt::PasswdMD5
Once you have run the above code in SSH try Easy Apache again.
That didn’t work…
If the above code didn’t work run the following in SSH
# install Digest::SHA1 Crypt::PasswdMD5
After running this try Easy Apache in WHM again and eveything should be working just fine!