From 78bdc0e5d666c6cd6740c6e5d374a6a97fd15e4a Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 27 May 2019 04:31:21 -0600 Subject: [PATCH] check borg return codes --- backup_new.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backup_new.sh b/backup_new.sh index 6f115f8..9d133dc 100755 --- a/backup_new.sh +++ b/backup_new.sh @@ -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