From 4bc31ad27490c088087cada653d58fe0cac2adb8 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 20 Oct 2018 04:47:50 -0600 Subject: [PATCH] save redis state --- root/scripts/backup.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/root/scripts/backup.sh b/root/scripts/backup.sh index 87c7f3e..9ba99bb 100644 --- a/root/scripts/backup.sh +++ b/root/scripts/backup.sh @@ -268,7 +268,7 @@ warningExplain[2201]="Borg exited with an unknown return-code. Please check this warningExplain[2210]="Borg prune exited with warnings. Please check this script's logfile for details" warningExplain[2212]="Borg prune exited with an unknown return-code. Please check this script's logfile for details" warningExplain[1001]="There was a problem dumping the SQL database. It has NOT been backed up" - +warningExplain[1002]="There was a problem saving redis state information. It has NOT been backed up" ### Process script parameters @@ -488,7 +488,7 @@ fi ### Dump SQL echo -e "${op}${stamp} Dumping mailcow SQL database...${normal}" >> "$logFile" -docker-compose exec mysql-mailcow mysqldump --default-character-set=utf8mb4 -u${DBUSER} -p${DBPASS} ${DBNAME} > "$sqlDumpDir/$sqlDumpFile" 2>> "$logFile" +docker-compose exec mysql-mailcow mysqldump --default-character-set=utf8mb4 -u${DBUSER} -p${DBPASS} ${DBNAME} > "$sqlDumpDir/$sqlDumpFile" >> "$logFile" 2>&1 dumpResult=$(docker-compose exec mysql-mailcow echo "$?") # verify sql dump was successful if [ "$dumpResult" -eq 0 ]; then @@ -499,6 +499,19 @@ else fi +### Save redis state +echo -e "${op}${stamp} Saving redis state information...${normal}" >> "$logFile" +docker-compose exec redis-mailcow redis-cli save >> "$logFile" 2>&1 +checkResult=$(docker-compose exec redis-mailcow echo "$?") +# Verify save was successful +if [ "$checkResult" -eq 0 ]; then + echo -e "${ok}${stamp} -- [SUCCESS] redis state saved --${normal}" \ + >> "$logFile" +else + exitWarn+=('1002') +fi + + ### Call borgbackup to copy actual files echo -e "${op}${stamp} Pre-backup tasks completed, calling borgbackup..." \ "${normal}" >> "$logFile"