From 076bb4fa6d0c5a1e63b019848709969949dc191c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 6 Oct 2014 00:17:13 +0200 Subject: [PATCH] Add a wrapper script for running everything in parallel again and output the logs in one go. --- backup-cron.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 backup-cron.sh diff --git a/backup-cron.sh b/backup-cron.sh new file mode 100755 index 0000000..6800136 --- /dev/null +++ b/backup-cron.sh @@ -0,0 +1,43 @@ +#! /bin/sh + +bindir=/home/backup # Location of backup.sh +confdir=/home/backup/conf/ # Configuration files + +logbasename=`$bindir/logfilename.sh` + +# The computers we want to back up +unixcomputers=`cat $confdir/computers.unix \ + | grep -v "^#" \ + | grep -v "^$" ` + +# Take the backups in parallel, but wait with actually outputting the logs +# until we have them all and can output them nicely in sequence. +for computer in $unixcomputers; do + ( + $bindir/backup.sh $computer \ + >>$logbasename.$computer.stdout \ + 2>>$logbasename.$computer.stderr \ + || touch $logbasename.failed + ) & +done + +wait + +# Output the logs. +if [ -f "$logbasename.failed" ]; then + echo "One or more backup jobs failed." +else + echo "All backups successful." +fi + +echo "" +echo "" +echo "Individual logs from each backup follow:" +echo "" + +for computer in $unixcomputers; do + echo "$computer" + echo "==============" + cat $logbasename.$computer.stdout + echo "" +done -- 2.39.2