Skip to end of metadata
Go to start of metadata


How can I backup and restore individual cPanel accounts with R1Soft CDP?


cPanel account backups are made with the cpbackup or pkgacct utilities in cPanel.  In addition to the account's or account's home directory files there are dumps of configuration and database queries run by pkgacct.  The full details are available here.  Some of the contents of a cPanel account backup can only be obtained from your WHM server while it is running. 

You can always restore the entire state of your WHM server and all cPanel accounts from a CDP recovery point by restoring all files or performing a bare-metal restore.  However, you may at times need to restore only individual cPanel accounts, for example when a cancelled customer decides they want to activate or for accidental changes made to any of the account's configuration in cPanel.

Using the example script below you can periodically create cPanel account backups that do not include the files in the account's home directory since those can easily be obtained by restoring files from a CDP recovery point.

Creating Periodic cPanel Account Packages that Get Protected by CDP

Upload or copy the script below to a file in the directory /etc/cron.daily on your WHM server.  This script will create a package of all your cPanel accounts excluding the /home directory files.


  • If you have a very large number of accounts on your WHM server it may only be feasible to run this weekly.  This can be accomplished by placing the script in /etc/cron.weekly.  
  • The script uses the ionice utility which requires the CFQ io scheduler and kernel 2.6.13+.  If you do not have the ionice utility available remove "ionice -c3" from the script.
  • Ensure you have enough free space in /home to accommodate the size of the account packages created.

#!/usr/bin/perl   # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.   BEGIN { unshift @INC, '/usr/local/cpanel'; }   use Cpanel::Config::Users  ();   my @cpusers = Cpanel::Config::Users::getcpusers(); foreach my $user (@cpusers) {     my $cmd = "nice -n 19 ionice -c3 /scripts/pkgacct --skiphomedir " . $user . " 2>&1";   print "############## ";   print $cmd;   print "\n";   open my $OUTPUT, '-|', $cmd or next;   while (<$OUTPUT>) {     print $_;   }   close $OUTPUT or next; }

The resulting configuration backup will be placed in: /home/cpmove-USERNAME.tar.gz and will be automatically backed up by CDP as long as you have selected the /home file system or disk in your Disk Safe for protection.

Restoring an Individual cPanel Account
  1. Use CDP (as the server administrator) to restore the file /home/cpmove-USERNAME.tar.gz to an alternate location (e.g. /tmp)
  2. Login to the cPanel server using SSH and run:  # /scripts/restorepkg --force /tmp/cpmove-USERNAME.tar.gz
  3. Restore the contents of the /home/USERNAME using CDP file restore
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.