Compare commits
4 Commits
1c85071ca4
...
090ce7d7fb
Author | SHA1 | Date |
---|---|---|
Asif Bacchus | 090ce7d7fb | |
Asif Bacchus | 709be1ef98 | |
Asif Bacchus | cabd5d75f2 | |
Asif Bacchus | 5222e9e08a |
|
@ -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,14 +133,15 @@ 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
|
||||
includeXtra=0
|
||||
exclusions=0
|
||||
# borg output verbosity -- normal
|
||||
borgCreateParams='--stats'
|
||||
borgPruneParams='--list'
|
||||
|
||||
# 503 related
|
||||
use503=0
|
||||
|
@ -343,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"
|
||||
|
@ -413,7 +417,7 @@ printf "${ok}[%s] -- [SUCCESS] SQL databases dumped successfully --${norm}\n" \
|
|||
|
||||
|
||||
### pre-backup tasks completed -- move to borg tasks
|
||||
printf "${cyan}[%s] -- [INFO] Pre-backup tasks completed --${norm}\n" \
|
||||
printf "${ok}[%s] -- [SUCCESS] Pre-backup tasks completed --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
|
||||
|
||||
|
@ -459,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"
|
||||
|
@ -556,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."
|
||||
|
@ -564,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
|
||||
|
||||
|
||||
|
@ -579,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
|
||||
|
@ -590,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."
|
||||
|
@ -599,18 +608,34 @@ if [ -n "${borgPruneResult}" ]; then
|
|||
"$(stamp)" >> "$logFile"
|
||||
printf "return code. Review this logfile for details --${norm}\n" \
|
||||
>> "$logFile"
|
||||
warnCount=$((warnCount+1))
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
### all processes successfully completed, cleanup and exit gracefully
|
||||
|
||||
# note successful completion of borg commands
|
||||
printf "${ok}[%s] -- [SUCCESS] Backup operations completed --${norm}\n" \
|
||||
"$(stamp)" >> "$logFile"
|
||||
|
||||
# cleanup
|
||||
cleanup
|
||||
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
### error codes
|
||||
# 1: parameter error
|
||||
# 2: not run as root
|
||||
|
|
Loading…
Reference in New Issue