Using cPanel/WHM it is very easy to transfer an existing cPanel account between servers. Coordinating this with a client who manages DNS on their own can make things a bit tricky, especially when their MX records point to the same server for webmail service.
In order to guarantee no downtime on the site, typically I copy a cPanel account over to the new server including all site files and email in advance of notifying a client it is okay to change the DNS. I also tell the site at the newly located cPanel account to continue to read and write to the original database on the old server using the server’s IP address as the host. This gives the client the flexibility to change the DNS at a time convenient for them.
Once the DNS has propagated to the new server, a bit of cleanup is required. Following the example above,
localhost.To accomplish #1 above is simple. Via SSH on the new server run the following commands
mysqladmin drop your_database_name
# Now update your site to point to localhost instead of the original server's IP
Then, from the original server run the following commands
mysqldump -u your_cpanel_user -p your_database_name | ssh your_cpanel_user@the_new_server_ip mysql your_database_name
This will minimize downtime for your users1 while updating the site to read/write from the local copy of the database now containing the newest information.
Item #2 above is equally simple via rsync from the old server
rsync -av --progress /home/your_cpanel_user/mail/ root@the_new_server_ip:/home/your_cpanel_user/mail
This command properly updates the new mail server’s mail folder for all users with the latest changes to their accounts prior to the MX record change.
It goes without saying that this work should be done very late at night. ↩