diff --git a/backup_new.sh b/backup_new.sh index 3f434ce..a505e9e 100755 --- a/backup_new.sh +++ b/backup_new.sh @@ -53,6 +53,7 @@ cleanup () { printf " Web interface will not function until this file is " \ >> "$logFile" printf "removed --${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) else printf "${cyan}[%s] -- [INFO] 503 error page removed --${norm}\n" \ "$(stamp)" >> "$logFile" @@ -64,6 +65,7 @@ cleanup () { "$(stamp)" >> "$logFile" printf "SQL dump directory at %s. " "$sqlDumpDir" >> "$logFile" printf "Remove manually to free up space.${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) else printf "${cyan}[%s] -- [INFO] Temporary SQL dump directory " \ "$(stamp)" >> "$logFile" @@ -131,9 +133,7 @@ stamp () { scriptPath="$( CDPATH='' cd -- "$( dirname -- "$0" )" && pwd -P )" scriptName="$( basename "$0" )" logFile="$scriptPath/${scriptName%.*}.log" -# borg output verbosity -- normal -borgCreateParams='--stats' -borgPruneParams='--list' +warnCount=0 configDetails="$scriptPath/seafbackup.details" err503Copied=0 sqlCopied=0 @@ -346,6 +346,7 @@ if [ "$use503" -eq 1 ]; then printf "${warn}[%s] -- [WARNING] Failed to copy 503 error page. " \ "$(stamp)" >> "$logFile" printf "Web users will NOT be notified --${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) else printf "${ok}[%s] -- [SUCCESS] 503 error page copied --${norm}\n" \ "$(stamp)" >> "$logFile" @@ -462,6 +463,7 @@ else printf "${warn} -- [WARNING] Using a borg repo without a password is an " \ >> "$logFile" printf "insecure configuration --${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) # if this was an accident, we need to provide a bogus passwd so borg fails # otherwise it will sit forever just waiting for input export BORG_PASSPHRASE="DummyPasswordSoBorgFails" @@ -559,6 +561,7 @@ elif [ "$borgResult" -eq 1 ]; then printf "${warn}[%s] -- [WARNING] Borg completed with warnings. " \ "$(stamp)" >> "$logFile" printf "Review this logfile for details --${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) elif [ "$borgResult" -ge 2 ]; then err_1="Borg exited with a critical error. Please review this log file" err_2="for details." @@ -567,6 +570,7 @@ else printf "${warn}[%s] -- [WARNING] Borg exited with unknown return code. " \ "$(stamp)" >> "$logFile" printf "Review this logfile for details --${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) fi @@ -582,6 +586,7 @@ else "$(stamp)" >> "$logFile" printf "Your archive will continue growing with each backup --${norm}\n" \ >> "$logFile" + warnCount=$((warnCount+1)) fi ## report on prune operation if executed @@ -593,6 +598,7 @@ if [ -n "${borgPruneResult}" ]; then printf "${warn}[%s] -- [WARNING] Borg prune completed with warnings. " \ "$(stamp)" >> "$logFile" printf "Review this logfile for details --${norm}\n" >> "$logFile" + warnCount=$((warnCount+1)) elif [ "$borgPruneResult" -ge 2 ]; then err_1="Borg prune exited with a critical error. Please review this" err_2="log file for details." @@ -602,6 +608,7 @@ if [ -n "${borgPruneResult}" ]; then "$(stamp)" >> "$logFile" printf "return code. Review this logfile for details --${norm}\n" \ >> "$logFile" + warnCount=$((warnCount+1)) fi fi @@ -615,11 +622,16 @@ printf "${ok}[%s] -- [SUCCESS] Backup operations completed --${norm}\n" \ # cleanup cleanup -# note complete success and exit +# note complete success, tally warnings and exit printf "${ok}[%s] -- [SUCCESS] All processes completed --${norm}\n" \ "$(stamp)" >> "$logFile" printf "${mag}[%s] --- %s execution completed ---${norm}\n" \ "$(stamp)" "$scriptName" >> "$logFile" +if [ "$warnCount" -gt 0 ]; then + printf "${warn}%s warnings issued!${norm}\n" "${warnCount}" >> "$logFile" +else + printf "${ok}0 warnings issued.${norm}\n" >> "$logFile" +fi exit 0