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.
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.
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.
- Use CDP (as the server administrator) to restore the file /home/cpmove-USERNAME.tar.gz to an alternate location (e.g. /tmp)
- Login to the cPanel server using SSH and run: # /scripts/restorepkg --force /tmp/cpmove-USERNAME.tar.gz
- Restore the contents of the /home/USERNAME using CDP file restore