Annotation of sludge_scripts/backup.sh, revision 1.5

1.5     ! nick        1: #!/bin/bash -x
1.1       nick        2: 
1.5     ! nick        3: VERSION="$Id: backup.sh,v 1.4 2011-06-17 16:17:17 nick Exp $"
1.1       nick        4: REMOTE="nick@demandred.dyndns.org"
1.5     ! nick        5: OPTIONS=-avxz -e ssh --delete
1.1       nick        6: LOGDIR=/home/backup/logs
                      7: DATE=`date +%Y%m%d`
                      8: 
1.3       nick        9: 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 )
                     10: 
                     11: WINSHARE_DIRS=( /home/winshare/Documents /home/winshare/Pictures /home/winshare/Receipts "/home/winshare/Shared Docs" /home/winshare/Backgrounds )
1.1       nick       12: 
                     13: 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)
                     14: 
                     15: [ -d $LOGDIR ] || mkdir -p $LOGDIR
                     16: 
                     17: cd /home/backup/backups
                     18: 
1.4       nick       19: SAVEIFS=$IFS
1.3       nick       20: for bdir in demandred winshare lanfear;
                     21: do
1.4       nick       22:        IFS=$(echo -en "\n\b")
1.3       nick       23:        [ "$bdir" == "demandred" ] && DIRS=(${DEMANDRED_DIRS[@]})
                     24:        [ "$bdir" == "winshare" ]  && DIRS=(${WINSHARE_DIRS[@]})
                     25:        [ "$bdir" == "lanfear" ]   && DIRS=(${LANFEAR_DIRS[@]})
                     26:        mkdir -p $bdir
                     27:        cd $bdir
                     28:        for DIR in "${DIRS[@]}"; do
                     29:                /usr/bin/rsync $OPTIONS $REMOTE:$DIR . >> $LOGDIR/backup-$DATE.log 2>&1
                     30:        done
                     31:        cd - > /dev/null 2>&1
1.1       nick       32: done
1.4       nick       33: IFS=$SAVEIFS
1.1       nick       34: 
                     35: ##
                     36: ## Compress logs after 5 days and delete logs after 6 months
                     37: ##
                     38: find $LOGDIR -type f -name \*.gz -mtime +180 -exec rm -f {} \;
                     39: find $LOGDIR -type f -name \*.log -mtime +5 -exec gzip -9 {} \;

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