--- sludge_scripts/backup.sh 2011/06/17 16:36:20 1.5 +++ sludge_scripts/backup.sh 2011/06/23 13:32:48 1.7 @@ -1,36 +1,22 @@ -#!/bin/bash -x +#!/bin/bash -VERSION="$Id: backup.sh,v 1.5 2011/06/17 16:36:20 nick Exp $" -REMOTE="nick@demandred.dyndns.org" -OPTIONS=-avxz -e ssh --delete -LOGDIR=/home/backup/logs -DATE=`date +%Y%m%d` - -DEMANDRED_DIRS=( /home/nick/database-backup.dump.gz /home/nick/database-backup.dump.yesterday.gz /home/nick/DroidBackups /home/cvs /home/nick/bbs /home/nick/notes /home/httpd /home/nick/Documents /home/nick/mail /home/nick/mail-backup ) - -WINSHARE_DIRS=( /home/winshare/Documents /home/winshare/Pictures /home/winshare/Receipts "/home/winshare/Shared Docs" /home/winshare/Backgrounds ) - -LANFEAR_DIRS=(/home/backup/systems/lanfear/home/nick/Documents /home/backup/systems/lanfear/home/nick/Receipts "/home/backup/systems/lanfear/home/nick/Nick\'s Pictures" /home/backup/systems/lanfear/home/nick/projects /home/backup/systems/lanfear/home/nick/notes) +declare VERSION="$Id: backup.sh,v 1.7 2011/06/23 13:32:48 nick Exp $" +declare LOGDIR="/home/backup/logs" +declare SCRIPT="/home/backup/scripts/backup.pl" +declare DATE=`date +%Y%m%d` [ -d $LOGDIR ] || mkdir -p $LOGDIR -cd /home/backup/backups +[ -x $SCRIPT ] || \ +{ + echo "ERROR: Missing $SCRIPT" + exit 1 +} -SAVEIFS=$IFS -for bdir in demandred winshare lanfear; -do - IFS=$(echo -en "\n\b") - [ "$bdir" == "demandred" ] && DIRS=(${DEMANDRED_DIRS[@]}) - [ "$bdir" == "winshare" ] && DIRS=(${WINSHARE_DIRS[@]}) - [ "$bdir" == "lanfear" ] && DIRS=(${LANFEAR_DIRS[@]}) - mkdir -p $bdir - cd $bdir - for DIR in "${DIRS[@]}"; do - /usr/bin/rsync $OPTIONS $REMOTE:$DIR . >> $LOGDIR/backup-$DATE.log 2>&1 - done - cd - > /dev/null 2>&1 -done -IFS=$SAVEIFS +## +## 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