Migrating a cPanel server between Cloud Hosting Providers

This post is a quick run down of the steps for migrating servers so the next time I have all the steps in one place. The scenario in this case is we’re migrating a school’s server from Linode to Digital Ocean. In preparation for such a migration you need to make sure that a) we have control over the DNS for the domain (i.e. it is registered through Reclaim) or b) the domain is using a CNAME record rather than an A record. Why? CNAMES point to host names like stateu.reclaimhosting.com rather than an IP address. When moving servers the IP address will most likely change, whereas hostnames do not—which means by using CNAME records the DNS switching will be seamless.

So, once you can confirm you control the domain and/or it’s pointed to a CNAME you can start the process.

1) Setup cPanel on the target server (in this case Digital Ocean) using Reclaim’s deploy script
2) Update your local host records to point to target server’s IP address
3) Login to the target server and use the Transfer tool in cPanel to move all account from the old server (in this scenario Linode) to the target server (Digital Ocean)
4) When using the Transfer tool make sure you enter the IP of the old server rather than a hostname
5) After all the accounts have moved successfully point the hostname (which for Reclaim is in AWS’s Route 53) to the IP of the new server on Digital Ocean
6) You will also need to update the DNS Cluster on the nameservers (both ns1 and ns2) with the new API token or access hash
7) The final bit is to make sure all traffic hitting old server is redirected to new server using this guide

Here’s the code to enter in the command line on the old server:

echo “1” > /proc/sys/net/ipv4/ip_forward
sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination your.target.IP.address.here:80
iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination your.target.IP.address.here:443
iptables -t nat -A POSTROUTING -j MASQUERADE

The other thing particular to Reclaim is that monitoring is using a URL so that will not change, but R1Soft (our backup solution) will need to have the public key refreshed. 

And that should do it.

This entry was posted in sysadmin and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.