From 5e5e50b8e8f625e0ee3c831172880a4abba57721 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 27 May 2019 05:08:09 -0600 Subject: [PATCH] execute borg prune and report results --- backup_new.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/backup_new.sh b/backup_new.sh index 9d133dc..dcf875f 100755 --- a/backup_new.sh +++ b/backup_new.sh @@ -552,7 +552,7 @@ elif [ "$borgResult" -eq 1 ]; then "$(stamp)" >> "$logFile" printf "Review this logfile for details --${norm}\n" >> "$logFile" elif [ "$borgResult" -ge 2 ]; then - exitError 139 "Borg exited with a critical error. \ + exitError 138 "Borg exited with a critical error. \ Review this log for details" else printf "${warn}[%s] -- [WARNING] Borg exited with uknown return code. " \ @@ -561,6 +561,46 @@ else fi +### execute borg prune if paramters are provided, otherwise skip with a warning +if [ -n "${borgPruneSettings}" ]; then + printf "${cyan}[%s] -- [INFO] Executing borg prune operation --${norm}\n" \ + "$(stamp)" >> "$logFile" + borg prune --show-rc -v ${borgPruneParams} ${borgPruneSettings} \ + 2>> "$logFile" + borgPruneResult="$?" +else + printf "${warn}[%s] -- [WARNING] No prune parameters provided. " \ + "$(stamp)" >> "$logFile" + printf "Your archive will continue growing with each backup --${norm}\n" \ + >> "$logFile" +fi + +## report on prune operation if executed +if [ -n "${borgPruneResult}" ]; then + if [ "${borgPruneResult}" -eq 0 ]; then + printf "${ok}[%s] -- [SUCCESS] Borg prune completed --${norm}\n" \ + "$(stamp)" >> "$logFile" + elif [ "$borgPruneResult" -eq 1 ]; then + printf "${warn}[%s] -- [WARNING] Borg prune completed with warnings. " \ + "$(stamp)" >> "$logFile" + printf "Review this logfile for details --${norm}\n" >> "$logFile" + elif [ "$borgPruneResult" -ge 2 ]; then + exitError 139 "Borg prune exited with a critical error. \ + Review this log for details" + else + printf "${warn}[%s] -- [WARNING] Borg prune exited with an unknown " \ + "$(stamp)" >> "$logFile" + printf "return code. Review this logfile for details --${norm}\n" \ + >> "$logFile" + fi +fi + + + + + + + exit 0 @@ -577,4 +617,6 @@ exit 0 # 116: could not dump SEAFILE-DB # 117: could not dump SEAHUB-DB # 130: null borg configuration variable -# 131: invalid borg configuration variable \ No newline at end of file +# 131: invalid borg configuration variable +# 138: borg exited with a critical error +# 139: borg prune exited with a critical error \ No newline at end of file