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