Clean Orphaned cPanel Backups
Posted: Mon Mar 14, 2011 1:14 pm
When you delete accounts, cpanel does not remove the associated backup which can cause a lot of uneeded disk usage over time.
I mocked up this 'clean orphaned backups' script this morning out of boredom. If DELETE is not equal to yes, the script will only print what it would delete
I mocked up this 'clean orphaned backups' script this morning out of boredom. If DELETE is not equal to yes, the script will only print what it would delete
Code: Select all
#!/bin/sh
BACKUP_DIR=/backup/cpbackup/daily
HOME=/home
KEEP=(cpbackupstatus.cfg dirs files)
DELETE=no
for x in `ls ${BACKUP_DIR}`; do
ls ${HOME}/${x} > /dev/null 2>&1
if [ $? != 0 ]; then
if ! echo ${KEEP[*]} | grep ${x} > /dev/null 2>&1; then
echo "Deleting ${x}"
if [ ${DELETE} == "yes" ]; then
rm -rf ${BACKUP_DIR}/${x}
fi
fi
fi
done