check borg return codes

This commit is contained in:
Asif Bacchus 2019-05-27 04:31:21 -06:00
parent 33416f8144
commit 78bdc0e5d6
1 changed files with 20 additions and 0 deletions

View File

@ -540,6 +540,26 @@ fi
# execute borg
${borgCMD} 2>> "$logFile"
borgResult="$?"
## check borg exit status
if [ "$borgResult" -eq 0 ]; then
printf "${ok}[%s] -- [SUCCESS] Borg backup completed " \
"$(stamp)" >> "$logFile"
printf "successfully --${norm}\n" >> "$logFile"
elif [ "$borgResult" -eq 1 ]; then
printf "${warn}[%s] -- [WARNING] Borg completed with warnings. " \
"$(stamp)" >> "$logFile"
printf "Review this logfile for details --${norm}\n" >> "$logFile"
elif [ "$borgResult" -ge 2 ]; then
exitError 139 "Borg exited with a critical error. \
Review this log for details"
else
printf "${warn}[%s] -- [WARNING] Borg exited with uknown return code. " \
"$(stamp)" >> "$logFile"
printf "Review this logfile for details --${norm}\n" >> "$logFile"
fi
exit 0