How to migrate all cPanel accounts without its home directory?

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 large amount of data, this will increase the total time for the account migration.

Generating backup and restoring it for a large account is much time consuming process. If you need a faster solution, exclude the home directory then complete the account migration with out 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


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 $

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 [email protected]:/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 [email protected]:/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.

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

3 thoughts on “How to migrate all cPanel accounts without its home directory?

Leave a Reply

Your email address will not be published. Required fields are marked *