From ba212f738ffbc4e5879654926ce300a64e2cf606 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 8 Feb 2021 10:52:17 -0700 Subject: [PATCH] feature(RESTORE): clearer more accurate exit report messages - change exit messages based on errors, warnings, etc. - separate error codes for exit with non-crit err and/or warnings --- backup/restore.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/backup/restore.sh b/backup/restore.sh index 02bb6c7..8ebfe4b 100644 --- a/backup/restore.sh +++ b/backup/restore.sh @@ -353,17 +353,18 @@ fi #TODO: optionally reindex dovecot (parameter) ### exit gracefully -writeLog 'success' "All processes completed" -printf "%s[%s] --- %s execution completed ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" >>"$logfile" -# note non-terminating errors if [ "$errorCount" -gt 0 ]; then - printf "%s%s errors encountered!%s\n" "$err" "$errorCount" "$norm" >>"$logfile" + # note non-terminating errors + printf "%s[%s] --- %s execution completed with %s error(s) ---\n%s" "$err" "$(stamp)" "$scriptName" "$errorCount" "$norm" >>"$logfile" + exit 98 +elif [ "$warnCount" -gt 0 ]; then + printf "%s[%s] --- %s execution completed with %s warning(s) ---\n%s" "$yellow" "$(stamp)" "$scriptName" "$warnCount" "$norm" >>"$logfile" + exit 97 +else + writeLog 'success' "All processes completed" + printf "%s[%s] --- %s execution completed ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" >>"$logfile" + exit 0 fi -# note warnings -if [ "$warnCount" -gt 0 ]; then - printf "%s%s warnings issued!%s\n" "$yellow" "$warnCount" "$norm" >>"$logfile" -fi -exit 0 ### error codes: # 1: parameter error @@ -375,6 +376,8 @@ exit 0 # 11: cannot locate SQL dump in backup directory # 12: cannot start mysql-mailcow container # 13: restoring SQL dump was unsuccessful +# 97: script completed with 1 or more warnings +# 98: script completed with 1 or more non-terminating errors # 99: TERM signal trapped # 100: could not change to mailcow-dockerized directory # 101: could not stop container(s)