Archive for the ‘Migration’ Category


Is it possible?

Yeah, definitely! You can create a complete cPanel account backup by excluding the home directory. This is very important, because, if the home directory of cPanel accounts have a large amount of data, this will increase the total time for the account migration.

Generating backup and restoring it for a large account is the much time-consuming process. If you need a faster solution, exclude the home directory then complete the account migration without its home directory. After that start syncing the home directory from source to destination server 🙂

cPanel provides necessary scripts to do this kind of operations via server CLI (command line interface). Here I am listing those scripts for account migration.

Command to create a cPanel backup file

/scripts/pkgacct

Package account.


Important cPanel scripts

How to create cPanel backup without its home directory?

/scripts/pkgacct --skiphomedir user

Replace user with cPanel user name.

The cPanel script to restore an account is pasted below:

/scripts/restorepkg $backup.file.name.

I guess you all are familiar with those scripts. Here we go!!


This is a simple for loop to generate backups, sync that to remote host and remove that backup file from the source server after syncing them to remote host.

Here is the script for doing so:

for x in `\ls -A1 /var/cpanel/users/`; do /scripts/pkgacct --skiphomedir ${x} ; rsync -aP /home/cpmove-${x}.tar.gz -e ssh root@destination.server:/home/ ; rm -f /home/cpmove-${x}.tar.gz ; done

Replace destination.server with the IP address of destination server.

If you want to maintain those backups on the source server, remove the last entry.

for x in `\ls -A1 /var/cpanel/users/`; do /scripts/pkgacct --skiphomedir ${x} ; rsync -aP /home/cpmove-${x}.tar.gz -e ssh root@NEW-SERVER-IP:/home/ ; done

Yeah, you have successfully created backup files and synced those files to the remote server. Now you need to restore those backups to the destination server.

Execute the following command on destination server.

for x in `ls -A1 /home/cpmove*` ; do /scripts/restorepkg /home/${x} ; done

That’s it!!!

Wait wait, where is home directories? Yeah you need to sync home directories to destination server. Syncing directories is not a big task. Please execute the following command:

rsync -aP /home/ -e ssh root@destination.server:/home/

Rsync commands in details

Yup! You’ve successfully completed the account migration.
Change the name servers of those domains to load it from the new server.

Advertisements