From 09c1d903badce41e7a3253a24021b3705bce00c7 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 7 May 2020 00:58:27 -0600 Subject: [PATCH] move sql dump earlier in script Borg requires the default TMP dir be changed to avoid permissions issue. Moving earlier means SQL dumps to system default TMP location. --- backup/backup.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/backup/backup.sh b/backup/backup.sh index 3fb7409..01b855b 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -545,6 +545,18 @@ exclusions=1 fi +### set location of sql dump +# this is done before resetting default TMP dir for borg +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 + + ### create borg temp dir: ## python requires a writable temporary directory when unpacking borg and ## executing commands. This defaults to /tmp but many systems mount /tmp with @@ -564,17 +576,6 @@ 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 " \