In the course of migration of the server, it is a good practics  to perform the the data sync after updating the DNS.

The home directory on the cPanel server can be synced using the rsync command, but in case if you wish to perform the re-migration of all the databases only.

I am sure following script will help you in saving lot of time.


echo “Creating mysqldbbackup Directory To Store The Backup !!”

mkdir -p /home/mysqldbbackup

mkdir -p /home/mysqldbbackup/database/

sleep 2

echo “The List Of the Databases Can Be Verified at /home/mysqldbbackup/dbslist “

sleep 2

echo “Genrating The Backup”

DBS=”$(mysql -u root -h localhost -Bse ‘show databases’)”
echo > /home/mysqldbbackup/dbslist
for db in $DBS
if [ $db != “information_schema” ] && [ $db != “cphulkd” ] && [ $db != “leechprotect” ] && [ $db != “eximstats” ] && [ $db != “modsec” ] && [ $db != “mysql” ] && [ $db != “roundcube” ] && [ $db != “horde” ]; then
echo $db >> /home/mysqldbbackup/dbslist

for i in `cat /home/mysqldbbackup/dbslist` ; do
/usr/bin/mysqldump –user=root –protocol=socket –socket=”/var/lib/mysql/mysql.sock” –skip-add-locks $i > /home/mysqldbbackup/database/$i.sql;

echo “The DataBase Backup is Stored At /home/mysqldbbackup/database !!!”


The working of the script, this script will take the backup of all the accounts database on the cPanel server in the folder /home/mysqldbbackup/database, the list of the databases will be created at /home/mysqldbbackup/dbslist.

Once this is done you may sync the /home/mysqldbbackup folder with the following command.

rsync -vrplogDtH -e “ssh -p22” /home/mysqldbbackup root@destination_server_IP_Address:/home/


Now when you have completed the sync you may restore all the databases with the following command.

for i in `cat /home/mysqldbbackup/dbslist` ; do /usr/bin/mysql –user=root –protocol=socket –socket=”/var/lib/mysql/mysql.sock” $i < /home/mysqldbbackup/database/$i.sql; done