Bump version to 3.0.
[wizbackup.git] / wizbackup-driver
index 6fbc2fdd2c257eb393d2668d1e99b104f7729638..957571cb757ed9f3a2857ffd5677b75dcb54bfa7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
 #!/bin/bash
 #
-# WizBackup Driver 1.0
+# WizBackup Driver 1.1
 # Copyright 2011 Bernie Innocenti <bernie@codewiz.org>
 #
 #  This program is free software: you can redistribute it and/or modify
 # Copyright 2011 Bernie Innocenti <bernie@codewiz.org>
 #
 #  This program is free software: you can redistribute it and/or modify
@@ -40,8 +40,12 @@ mkdir -p $LOCKDIR
 
 if [ "`tty`" = "not a tty" ]; then
        LOGFILE="$LOGDIR/$LOGGROUP-$today.log"
 
 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
 else
        LOGFILE=/dev/stdout
+       FAILLOG=/dev/stderr
+       REPORT=/dev/stdout
 fi
 
 for host in $HOSTS; do
 fi
 
 for host in $HOSTS; do
@@ -51,14 +55,19 @@ for host in $HOSTS; do
        done
 
        start_time=$(date +%s)
        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"
        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
 
 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