prekillacct – backup cpanel accounts on termination

by brian on February 2, 2010

Ever terminate a cPanel account by mistake? This script backs up a cPanel account as it is terminated.

That makes it really easy to restore the current state of the account if it is accidentally deleted via killacct or WHM/Terminate. Without this script, you have to rely on your last backup, which may or may not be recent and may or may not have even worked; at best, you may have lost hours of email or database changes.

The script works as killacct, which implements the account termination, runs the script /scripts/prekillacct before it does the actual kill. It does a pkgacct backup of the account, and copies a few useful statistics including DNS zones and maxemails into the home directory before the backup is made.

The account backup is kept in /backup/deleted and that directory is rsync’ed to /home/deleted at the end of the script. That makes it possible to lose /backup, or lose /home, without losing your backup of deleted accounts. To undelete an account after deletion, simply copy the backup to /home or /home2 and go into WHM/Restore acct and enter the username (you’ll see the backup file there).

To use this script, simply copy it to /scripts/prekillacct and make it mode 755 (ie: chmod 755 /scripts/prekillacct).

[download id=”3″]

Original release: August 2009

Previous post:

Next post: