Code SnippetsServer Configuration

Backup & Restore cPanel / WHM accounts via SSH

By March 11, 2014 No Comments

I found this excellent post here and don’t want to loose it: http://drewsymo.com/2013/11/backup-restore-cpanel-whm-accounts-via-ssh/

cPanel / WHM comes with a powerful backup and restore feature. Let’s learn how to use this feature via command-line / SSH.

Aside: cPanel / WHM has a wide variety of [scripts][1] that can achieve your end goal. These scripts are located in /scripts/.

Backing up singular accounts with cPanel via SSH

Backing up a singular account is easy. Simply issue the following command to backup a cPanel account named ‘drewsymo’:

/scripts/pkgacct drewsymo

This particular script, ‘pkgacct‘ generates a ‘cpmove‘ .tar.gz file. This file will be stored in the home directory of your server, i.e:

/home/cpmove-drewsymo.tar.gz

Restoring an account with cPanel via SSH

Restoring an account from a ‘cpmove’ or auto-generated cPanel backup file is just as easy as backing one up.

To restore a ‘cpmove’ file, you will firstly need to make sure that the account is terminated:

/scripts/killacct drewsymo

Now, you can initiate a complete account restoration via the ‘restorepkg’ command:

/scripts/restorepkg drewsymo

Note: the ‘cpmove’ file will need to be moved to the /home/ directory in order to initiate the above command successfully.

The latter command can be used to restore a generic auto-generated cPanel backup file (this will overwrite existing files if the account already exists and is generally not recommended)

Backing up all accounts on a cPanel Server via SSH

If you would like to backup all accounts on a cPanel / WHM server, simply issue the following command:

/scripts/cpbackup

Robert Rooke

Author Robert Rooke

More posts by Robert Rooke

Leave a Reply