From 74e6abb81d4a4efca96918ef678f25a13f33379c Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Thu, 9 May 2024 15:43:37 +0200 Subject: [PATCH] Handle errors of the sync steps --- bup-sync-trigger.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bup-sync-trigger.sh b/bup-sync-trigger.sh index 0fac4af..35f82d8 100755 --- a/bup-sync-trigger.sh +++ b/bup-sync-trigger.sh @@ -136,6 +136,8 @@ fi echo "The backup script is triggered." date +errored= + while read line do echo "Processing line $line" @@ -143,13 +145,26 @@ do then echo "Shipping to call script $line as in dry mode." else - $line + tmp=$(mktemp) + $line 2> "$tmp" && echo "Done" || { + echo "Command failed: $line" + echo "Logs:" + cat "$tmp" + errored=y + } + rm -f "$tmp" fi done <<< $(cat "$repoFile" | grep -v '^#' | sed '/^\W*$/d') echo "All sync scripts have been run." date +if [ -n "$errored" ] +then + echo "An error had happened. Aborting" + exit 1 +fi + if [ -n "$dryRun" ] then echo "Not updating the trigger timestamp. The value would be $(getNextDate)."