Backup for Specific cPanel user using cron

From brokenpoet.org wiki

A simple script allowing more frequent backups with a rotation schedule



wget http://scripts.brokenpoet.org/backupforusr-cronjob.sh



#!/bin/bash
# written by benjamin cathey 2008.06.18
#
# intended as a cron job on cpanel systems to backup a user account more
# frequently than normal - in this case it runs every 4 hours and keeps
# 2 backups (removing the directory 8 hours old when it runs using the
# -mmin option in find)
# 
#
# pretty specific but my be usable in other instances.
 
cdate=$(date +%Y%m%d-%H)
user="solorg"
newdir="/backup/$user/$cdate"

mkdir $newdir
/scripts/pkgacct $user $newdir/

for i in $(find /backup/solorg -type d -mmin +480 -name '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9]')
  do rm -rf $i
done

echo "backup completed on `date`"|mail -s "backup of $user on `hostname`" bcathey@liquidweb.com
Personal tools