Clean Orphaned cPanel Backups

If you have a program or script that you'd like to give away or sell, this is the place to do it. All offers should include contact info.

Moderators: BBear, theunknownhost, flaguy

Post Reply
User avatar
crashdump
Hard Drive Crasher
Posts: 950
Joined: Thu Oct 17, 2002 5:44 pm
Location: Virginia

Clean Orphaned cPanel Backups

Post by crashdump » 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

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

User avatar
khimaira2
Nothing better to do.
Posts: 202
Joined: Mon Sep 20, 2004 12:19 pm
Location: Location: Location:

Post by khimaira2 » Mon Mar 14, 2011 10:53 pm

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.

http://www.ndchost.com/cpanel-whm/plugins/

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.
Outside the box member

User avatar
crashdump
Hard Drive Crasher
Posts: 950
Joined: Thu Oct 17, 2002 5:44 pm
Location: Virginia

Post by crashdump » Mon Mar 14, 2011 11:21 pm

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.

User avatar
khimaira2
Nothing better to do.
Posts: 202
Joined: Mon Sep 20, 2004 12:19 pm
Location: Location: Location:

Post by khimaira2 » Tue Mar 15, 2011 11:20 pm

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.
Outside the box member

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest