How would you move/sync cpanel server to other machine with min. downtime?

postcd

Well-Known Member
Oct 22, 2010
721
21
68
Hello,

it may have been already discussed, but my issue is little specific, as i have cPanel on a VPS which i can backup and then restore.

In the near future i will need to move OpenVZ virtual private server with cpanel installed on it from one physical server to another within one datacenter.

I think i may use vzdump or openvz.org/Man/vzmigrate.8 vzmigrate tool which is using rsync to do VPS migration with minimum downtime.

The server IP will remain the same, my provider agreed that he can switch IP subnet between source and destination server at defined time.

Do you please have any advice regarding the migration from server to server so all important data are in sync before i allow access/writing into new/restored server files?

This is my rough plan and i hope you can help adjust it.
I can for example execute bash script to:

- create dump of whole cpanel VPS
- transfer + restore it on destination server
- service chkservd stop;service httpd stop;service mysqld stop;service pure-ftpd stop;service exim stop
- then i would need to execute rsync command to sync certain directories like mysql (which ones i should rsync) with destination server (which will have different IP because current IP is still routed to old machine)
- then i would need to either forward all visitors of old VPS to new VPS IP:
a)
Code:
iptables -t nat -I PREROUTING -p tcp -d OLD_IP_HERE --dport 80 -j DNAT --to NEW_IP_HERE
b) revsys.com/writings/quicktips/ssh-tunnel.html HOWTO: SSH Tunneling Made Easy
c) debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/ How-To: Redirecting network traffic to a new IP using IPtables
(will the sites work on new VPS IP even i temporarily has old VPS IPs in DNS zones etc.? Or what is the better solution to reduce time for which people can not access their websites?
- once IPs are routed to new machine, i assign correct IP to the new VPS and all starts working

Please do you have idea on commands or schedule that is more simple and allows shorter downtime?

Source and destination OS is CentOS 6.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Hello,

Your current plan seems solid, however I do have a couple of recommendations:

1. CentOS 7 is likely a better choice for the new server if you'd like it to be more future-proof.

2. The "Minimize Your Downtime" tab on the following document is helpful:

cPanel Migration Services and Guides - cPanel Knowledge Base - cPanel Documentation

Additionally, the following document offers some information you may find helpful:

How to Move All cPanel Accounts from One Server to Another - cPanel Knowledge Base - cPanel Documentation

3. You may want to backup and move the MySQL databases using a utility such as "mysqldump" when syncing your MySQL databases after the initial transfer. Simply moving the updated data with "rsync" after the initial transfer could lead to problems (e.g. InnoDB corruption).

Let us know if you have any questions.

Thank you.