Daily Incremental Account Backup in CPanel
Cpanel v64 removed what were true incremental backups in place of "incremental" full backups. This is great if you want restore points, but not if you want minimal impact backup operations and storage requirements. Fortunately you can still use the pkgacct operation to perform incremental backups. You can run this in addition to the modern CPanel backup system.
#/usr/bin/bash
BACKUP_DIR="/backup/daily-incremental/accounts"
# Loop through users and run pkgacct on any found in /home
cd /var/cpanel/users
for i in `ls *`
do
if [ -d "/home/$i" ]; then
/usr/local/cpanel/bin/pkgacct --incremental "$i "$BACKUP_DIR" backup
fi
done
# Loop through backup location and remove terminated accounts
cd "$BACKUP_DIR"
for i in `ls`
do
if [ ! -d "/home/$i" ]; then
rm "$BACKUP_DIR/$i" -rf
fi
done
```