Do not exit on backup failure

Exit caused email notifications to be not sent when backup fails. We especially
want to be notified if a backup fails.
This commit is contained in:
Esa Nuuros
2020-10-26 15:12:19 +02:00
parent 268987fd8e
commit 265c33f2d9

View File

@@ -31,18 +31,17 @@ logLast "AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}"
# Do not save full backup log to logfile but to backup-last.log
restic backup /data ${RESTIC_JOB_ARGS} --tag=${RESTIC_TAG?"Missing environment variable RESTIC_TAG"} >> ${lastLogfile} 2>&1
rc=$?
backupRC=$?
logLast "Finished backup at $(date)"
if [[ $rc == 0 ]]; then
echo "Backup Successfull"
if [[ $backupRC == 0 ]]; then
echo "Backup Successfull"
else
echo "Backup Failed with Status ${rc}"
echo "Backup Failed with Status ${backupRC}"
restic unlock
copyErrorLog
exit 1
fi
if [ -n "${RESTIC_FORGET_ARGS}" ]; then
if [[ $backupRC == 0 ]] && [ -n "${RESTIC_FORGET_ARGS}" ]; then
echo "Forget about old snapshots based on RESTIC_FORGET_ARGS = ${RESTIC_FORGET_ARGS}"
restic forget ${RESTIC_FORGET_ARGS} >> ${lastLogfile} 2>&1
rc=$?