]> arthur.barton.de Git - backup-script.git/commitdiff
backup-script-wrapper: Append log messages to an logfile
authorAlexander Barton <alex@barton.de>
Tue, 18 Aug 2015 08:17:00 +0000 (10:17 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 18 Aug 2015 08:17:00 +0000 (10:17 +0200)
bin/backup-script-wrapper

index 8ae3fc800e695461ac587366c3a3acea327cd5b8..7da3208657c056b51f6abf27bf7670e6e952d55a 100755 (executable)
@@ -23,6 +23,7 @@ fi
 NAME="backup-script"
 HOST=`hostname`
 TMP=`mktemp /tmp/$NAME.XXXXXXXX` || exit 11
+LOGFILE="/var/log/backup-script.log"
 
 PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
 export PATH
@@ -35,7 +36,12 @@ echo " - Host: `hostname -f`"
 echo " - User: `id -un`"
 echo
 
-"$(dirname "$0")/backup-script" "$@"
+if [ -w "$LOGFILE" ]; then
+       "$(dirname "$0")/backup-script" "$@" | tee -a "$LOGFILE"
+else
+       "$(dirname "$0")/backup-script" "$@"
+       echo "(Can't write logfile: \"$LOGFILE\"!)"
+fi
 
 cat "$TMP" | mail -s "$HOST: $NAME results" "$MAILTO"