Transfer cPanel accounts between servers with minimum downtime
The account migration is always annoying process because a System Administrator needs to do a lots of things fast and without errors.
This post provides the instructions about how to migrate the cPanel accounts between servers with minimum downtime, which is very important if you are running online business. The migration described in this post allows to switch the accounts between servers in less than 1 hour.
Login via SSH to the old server and run below code for each username account what you are going to backup:
The screen output will look similar to above screenshot. cPanel will place the backup archives to /home folder.
After that, transfer all backups to new server using scp command:
scp /home/cpmove-* firstname.lastname@example.org:/home/
Now, it is time to login to new server via SSH. On this server using another cPanel script, restore the backups for each username:
This command will restore the account from the backup and will create the account on new server.
Finally, login to old server's WHM, edit DNS zone for moved accounts and change the IP and nameservers. For minimum downtime I recommend to follow the tip Redirect WWW traffic while nameservers details are propagating
If you have multiple accounts to transfer (over 5), it is possible that typing backup/restore commands for each username would be annoying. To automatize backup/restore task, use this script:
#!/bin/bash accounts="account1 account2 account3" for account in $accounts do /scripts/pkgacct $account; done
The script automatically backups the accounts specified in accounts variable. Note that the script could be used for account restoring: just replace /scripts/pkgacct with /scripts/restorepkg.