]> git.sesse.net Git - backup.sh/commitdiff
Add a wrapper script for running everything in parallel again and output the logs...
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 5 Oct 2014 22:17:13 +0000 (00:17 +0200)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 5 Oct 2014 22:17:13 +0000 (00:17 +0200)
backup-cron.sh [new file with mode: 0755]

diff --git a/backup-cron.sh b/backup-cron.sh
new file mode 100755 (executable)
index 0000000..6800136
--- /dev/null
@@ -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