Page 1 of 1

Clean Orphaned cPanel Backups

Posted: Mon Mar 14, 2011 1:14 pm
by crashdump
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

Code: Select all


KEEP=(cpbackupstatus.cfg dirs files)

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}

Posted: Mon Mar 14, 2011 10:53 pm
by khimaira2
We don't want to knock your work and clever approach, but you might want to try this free plugin from NDCHost. Yes, they are a competitor but they do have a few freebies we have found to be most helpful.

The Clean Backups plugin also gets weekly and monthly backups if they exist and you can set the number of days before cleaning them out.

Posted: Mon Mar 14, 2011 11:21 pm
by crashdump
Thanks khimaira2. Your not knocking my work. I had found NDCHost's plugin, but since I was unfamiliar with their work, I decided to not to install it and do my own since it was such a simple issue.

Posted: Tue Mar 15, 2011 11:20 pm
by khimaira2
We can say we found their plugins easy to install and helpful. The DNS Check rarely provides any information of use, but we guess finding a single problem would make it worthwhile. The Mod_Security plugin does give a slightly different and useful perspective as a complement to the ConfigServer Mod_Security plugin. The Clean Backups plugin provides a nice interface with complete automation and logging.

All in all, they are pretty useful until Arf gets up to speed writing cpanel plugins.