X-Git-Url: https://codewiz.org/gitweb?p=wizbackup.git;a=blobdiff_plain;f=wizbackup-driver;h=957571cb757ed9f3a2857ffd5677b75dcb54bfa7;hp=1a5d0bc8bb06f24b0233ba46f7d0219e27a87ceb;hb=HEAD;hpb=de80ca1013f45886ee60ad3203598f9c79633bf5 diff --git a/wizbackup-driver b/wizbackup-driver index 1a5d0bc..957571c 100755 --- a/wizbackup-driver +++ b/wizbackup-driver @@ -1,6 +1,6 @@ #!/bin/bash # -# WizBackup Driver 1.0 +# WizBackup Driver 1.1 # Copyright 2011 Bernie Innocenti # # This program is free software: you can redistribute it and/or modify @@ -40,25 +40,34 @@ mkdir -p $LOCKDIR if [ "`tty`" = "not a tty" ]; then LOGFILE="$LOGDIR/$LOGGROUP-$today.log" + FAILLOG="$LOGDIR/$LOGGROUP-fail-$today.log" + REPORT="$LOGDIR/$LOGGROUP-report-$today.log" else LOGFILE=/dev/stdout + FAILLOG=/dev/stderr + REPORT=/dev/stdout fi for host in $HOSTS; do - opts="--exclude-from $EXCLUDES_DIR/ALWAYS" - if [ -f "$EXCLUDES_DIR/$host" ]; then - opts="$opts --exclude-from $EXCLUDES_DIR/$host" - fi + opts="" + for file in "$EXCLUDES_DIR/ALWAYS" "$EXCLUDES_DIR/$host"; do + [ -f $file ] && opts="$opts --exclude-from $file" + done start_time=$(date +%s) - flock $LOCKDIR/$host wizbackup "$host:/" "$DEST/$host/" $opts >>$LOGFILE 2>&1 + flock -n $LOCKDIR/$host nice ionice -c2 -n6 \ + wizbackup "$host:/" "$DEST/$host/" $opts >>$LOGFILE 2>&1 result=$? end_time=$(date +%s) report="$(date +%s):$host:$(($end_time-$start_time)):$result" - echo $report >>$LOGDIR/$LOGGROUP-report-$today.log - [ $result != 0 ] && echo "$report" >>$LOGDIR/$LOGGROUP-fail-$today.log + echo $report >>"$REPORT" + [ $result != 0 ] && echo "$report" >>"$FAILLOG" done -# TODO: send fail log email report -# TODO: delete logs older than 45 days +if [ -s "$FAILLOG" ]; then + cat "$FAILLOG" + exit 1 +fi + +# TODO: delete logs older than N days