Handle errors of the sync steps

This commit is contained in:
Christian Wolf 2024-05-09 15:43:37 +02:00
parent 45b686cf8f
commit 74e6abb81d

View File

@ -136,6 +136,8 @@ fi
echo "The backup script is triggered." echo "The backup script is triggered."
date date
errored=
while read line while read line
do do
echo "Processing line $line" echo "Processing line $line"
@ -143,13 +145,26 @@ do
then then
echo "Shipping to call script $line as in dry mode." echo "Shipping to call script $line as in dry mode."
else else
$line tmp=$(mktemp)
$line 2> "$tmp" && echo "Done" || {
echo "Command failed: $line"
echo "Logs:"
cat "$tmp"
errored=y
}
rm -f "$tmp"
fi fi
done <<< $(cat "$repoFile" | grep -v '^#' | sed '/^\W*$/d') done <<< $(cat "$repoFile" | grep -v '^#' | sed '/^\W*$/d')
echo "All sync scripts have been run." echo "All sync scripts have been run."
date date
if [ -n "$errored" ]
then
echo "An error had happened. Aborting"
exit 1
fi
if [ -n "$dryRun" ] if [ -n "$dryRun" ]
then then
echo "Not updating the trigger timestamp. The value would be $(getNextDate)." echo "Not updating the trigger timestamp. The value would be $(getNextDate)."