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