Automatically exclude backing up new accounts in cPanel

cPanel is setup so is that if automatic backups are enabled in WHM then every new account will be added to the backup list. If you’re picky about which accounts you want the be backed up and don’t want to manually exclude the accounts upon creation, you can use this method.

What the following code does is writes the username of the account currently being created to the system’s /etc/cpbackup-userskip.conf file to be excluded from backups.

Create (if not already there) /scripts/postwwwacct then copy and past the following code into the file:

#!/usr/bin/php
<?php
$opts = array();
$argv0 = array_shift($argv);

while(count($argv)) {
 $key = array_shift($argv);
 $value = array_shift($argv);
 $opts[$key] = $value;
}

$fp = fopen('/etc/cpbackup-userskip.conf','a');
fwrite($fp,$opts['user'].chr(10));
fclose($fp);
?>

All new accounts will now be excluded from the backup list!