4 # Copyleft 2011 Bernie Innocenti <bernie@codewiz.org>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License,
9 # or (at your option) any later version.
13 echo "Usage: $0 [MACHINE-TAB]"
15 echo "The MACHINE-TAB file contains hostnames of machines to be backed up, one per line."
16 echo "Empty lines and lines starting with '#' are ignored."
20 HOSTS=`cat $1 | egrep -v '^#|^ *$'`
22 LOGGROUP=`basename $1`
23 LOGDIR=/var/log/wizbackup
24 LOCKDIR=/var/lock/wizbackup
25 EXCLUDES_DIR=/root/rsync-backups/exclude
28 today=`date +"%Y%m%d"`
32 if [ "`tty`" = "not a tty" ]; then
33 OUTLOGFILE="$LOGDIR/$LOGGROUP-$today.log"
38 for host in $HOSTS; do
39 opts="--exclude-from $EXCLUDES_DIR/ALWAYS"
40 if [ -f "$EXCLUDES_DIR/$host" ]; then
41 opts="$opts --exclude-from $EXCLUDES_DIR/$host"
44 start_time=$(date +%s)
45 flock $LOCKDIR/$host wizbackup "$host:/" "$DEST/$host/" $opts >>$LOGFILE 2>&1
49 report="$(date):$host:$(($end_time-$start_time)):$result"
50 echo $report >>$LOGDIR/$LOGGROUP-report-$today.log
51 [ $result != 0 ] && echo "$report" >>$LOGDIR/$LOGGROUP-fail-$today.log
54 # TODO: send fail log email report
55 # TODO: delete logs older than 45 days