Compare commits

..

2 Commits

Author SHA1 Message Date
Asif Bacchus
fb6a2e9014 Clean old redis backup and then check if new backup > 0 bytes written 2018-10-25 10:37:17 -06:00
Asif Bacchus
6b91b93738 Moved docker volume location vars earlier in script 2018-10-25 10:10:13 -06:00

View File

@ -461,6 +461,13 @@ export logFile="$logFile"
### Export docker container startup timeout variable
export COMPOSE_HTTP_TIMEOUT=${dockerStartTimeout}
## Get docker volume paths on filesystem
dockerVolumeMail=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_vmail-vol-1)
dockerVolumeRspamd=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_rspamd-vol-1)
dockerVolumePostfix=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_postfix-vol-1)
dockerVolumeRedis=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_redis-vol-1)
dockerVolumeCrypt=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_crypt-vol-1)
### Create sqlDump temporary directory and sqlDumpFile name
sqlDumpDir=$( mktemp -d )
@ -578,12 +585,29 @@ checkExist fs "$sqlDumpDir/$sqlDumpFile"
fi
### Save redis state
## Delete any existing redis dump file otherwise our check will be useless
echo -e "${op}${stamp} Cleaning up old redis state backup...${normal}" \
>> "$logFile"
checkExist ff "$dockerVolumeRedis/dump.rdb"
checkResult="$?"
if [ "$checkResult" = "0" ]
echo -e "${lit}${stamp} Old redis backup found.${normal}" >> "$logFile"
echo -e "${op}Deleting...${normal}" >> "$logFile"
rm -f "$dockerVolumeRedis/dump.rdb" 2>> "$logFile"
echo -e "${op}${stamp}...done${normal}" >> "$logFile"
else
echo -e "${op}${stamp} No old redis backup found${normal}" \
>> "$logFile"
fi
## Export redis
echo -e "${op}${stamp} Saving redis state information...${normal}" >> "$logFile"
docker-compose exec redis-mailcow redis-cli save >> "$logFile" 2>&1
## redis outputs a simple 'OK' if the export succeeded, so check the log file
## for a line just written that says that specifically
if [ $(tail -1 "$logFile") = "OK" ];
echo -e "${ok}${stamp} -- [SUCCESS] redis state saved --${normal}" \
## although redis returns an 'OK' if successful, seemingly nothing can test for
## this... so let's just verify the dump file was written to disk
checkExist fs "$dockerVolumeRedis/dump.rdb"
checkResult="$?"
if [ "$checkResult" = "0" ]; then
echo -e "${ok}${stamp} -- [SUCCESS] redis state saved --${normal}" \
>> "$logFile"
else
exitError+=("${stamp}_202")
@ -747,14 +771,6 @@ fi
export TMPDIR="${BORG_BASE_DIR}/tmp"
## Get docker volume paths on filesystem for inclusion in backup
dockerVolumeMail=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_vmail-vol-1)
dockerVolumeRspamd=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_rspamd-vol-1)
dockerVolumePostfix=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_postfix-vol-1)
dockerVolumeRedis=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_redis-vol-1)
dockerVolumeCrypt=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_crypt-vol-1)
## Generate and execute borg
# commandline depends on whether borgExclude is empty or not
if [ -z "$borgExclude" ]; then