File:  [Local Repository] / sludge_scripts / backup.sh
Revision 1.6: download - view: text, annotated - select for diffs
Wed Jun 22 20:12:58 2011 UTC (13 years, 4 months ago) by nick
Branches: MAIN
CVS tags: HEAD
Due to problems in bash (or my scripting knowledge) I was having ongoing problems with spaces in the directory names.  I decided to convert the shell script to a wrapper to launch a perl script that actually calls rsync.  The shell wrapper still handles compressing and deleting old logs.

#!/bin/bash

declare LOGDIR="/home/backup/logs"
declare SCRIPT="/home/backup/scripts/backup.pl"
declare DATE=`date +%Y%m%d`

[ -d $LOGDIR ] || mkdir -p $LOGDIR

[ -x $SCRIPT ] || \
{
	echo "ERROR: Missing $SCRIPT"
	exit 1
}

##
## Call our perl script to handle the dirty work
##
$SCRIPT $LOGDIR >> $LOGDIR/backup-$DATE.log 2>&1

##
## Compress logs after 5 days and delete logs after 6 months
##
find $LOGDIR -type f -name \*.gz -mtime +180 -exec rm -f {} \;
find $LOGDIR -type f -name \*.log -mtime +5 -exec gzip -9 {} \;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>