From d9c662bb454e9693a5c414b2a7536ea4cb8c7a9d Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 6 May 2020 23:02:07 -0600 Subject: [PATCH] move sql temp dir creation and 503-copy moved to after borg configuration checks to consoldate checks vs actions --- .vscode/numbered-bookmarks.json | 18 +--------- backup/backup.sh | 62 ++++++++++++++++----------------- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index beade54..4c08963 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -1,19 +1,3 @@ { - "bookmarks": [ - { - "fsPath": "$ROOTPATH$/backup/backup.sh", - "bookmarks": [ - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - 401 - ] - } - ] + "bookmarks": [] } \ No newline at end of file diff --git a/backup/backup.sh b/backup/backup.sh index eaf6840..0bc6863 100644 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -399,37 +399,6 @@ printf "%s[%s] -- [INFO] Using MAILCRYPT volume: %s --%s\n" \ "$cyan" "$(stamp)" "$dockerVolumeCrypt" "$norm" >> "$logFile" -### set location of sql dump -if ! sqlDumpDir=$( mktemp -d 2>/dev/null ); then - exitError 115 'Unable to create temp directory for SQL dump.' -else - sqlDumpFile="backup-$( date +%Y%m%d_%H%M%S ).sql" - sqlDumpDirCreated=1 - printf "%s[%s] -- [INFO] SQL dump file will be stored at: %s --%s\n" \ - "$cyan" "$(stamp)" "$sqlDumpDir/$sqlDumpFile" "$norm" >> "$logFile" -fi - - -### 503 functionality -if [ "$use503" -eq 1 ]; then - printf "%s[%s] -- [INFO] Copying 503 error page to " \ - "$cyan" "$(stamp)" >> "$logFile" - printf "webroot -- %s\n" "$norm">> "$logFile" - if ! cp --force "${err503Path}" "${webroot}/${err503File}" 2>> "$logFile" - then - printf "%s[%s] -- [WARNING] Failed to copy 503 error page. " \ - "$warn" "$(stamp)" >> "$logFile" - printf "Web users will NOT be notified --%s\n" "$norm" >> "$logFile" - warnCount=$((warnCount+1)) - else - printf "%s[%s] -- [SUCCESS] 503 error page copied --%s\n" \ - "$ok" "$(stamp)" "$norm" >> "$logFile" - # set cleanup flag - err503Copied=1 - fi -fi - - ### read details file to get variables needed run borg # check if config details file was provided as a relative or absolute path case "${configDetails}" in @@ -560,6 +529,37 @@ fi export TMPDIR="${borgBaseDir}/tmp" +### set location of sql dump +if ! sqlDumpDir=$( mktemp -d 2>/dev/null ); then + exitError 115 'Unable to create temp directory for SQL dump.' +else + sqlDumpFile="backup-$( date +%Y%m%d_%H%M%S ).sql" + sqlDumpDirCreated=1 + printf "%s[%s] -- [INFO] SQL dump file will be stored at: %s --%s\n" \ + "$cyan" "$(stamp)" "$sqlDumpDir/$sqlDumpFile" "$norm" >> "$logFile" +fi + + +### 503 functionality +if [ "$use503" -eq 1 ]; then + printf "%s[%s] -- [INFO] Copying 503 error page to " \ + "$cyan" "$(stamp)" >> "$logFile" + printf "webroot -- %s\n" "$norm">> "$logFile" + if ! cp --force "${err503Path}" "${webroot}/${err503File}" 2>> "$logFile" + then + printf "%s[%s] -- [WARNING] Failed to copy 503 error page. " \ + "$warn" "$(stamp)" >> "$logFile" + printf "Web users will NOT be notified --%s\n" "$norm" >> "$logFile" + warnCount=$((warnCount+1)) + else + printf "%s[%s] -- [SUCCESS] 503 error page copied --%s\n" \ + "$ok" "$(stamp)" "$norm" >> "$logFile" + # set cleanup flag + err503Copied=1 + fi +fi + + ### execute borg depending on whether exclusions are defined ## construct the proper borg commandline