Compare commits
2 Commits
8bb9617e34
...
7e92495c94
Author | SHA1 | Date | |
---|---|---|---|
|
7e92495c94 | ||
|
0808888030 |
@ -571,10 +571,18 @@ fi
|
|||||||
|
|
||||||
### Dump SQL
|
### Dump SQL
|
||||||
echo -e "${op}${stamp} Dumping mailcow SQL database...${normal}" >> "$logFile"
|
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 \
|
||||||
## error checking sqldump within the container in a cron-friendly manner is a
|
-u${DBUSER} -p${DBPASS} ${DBNAME} > "$sqlDumpDir/$sqlDumpFile" \
|
||||||
## nightmare, so let's just see if a non-empty file with the expected name was
|
2>> "$logFile"
|
||||||
## created
|
dumpResult=$(docker-compose exec -T mysql-mailcow echo "$?")
|
||||||
|
## very mysqldump completed successfully
|
||||||
|
if [ "$dumpResult" = "0" ]; then
|
||||||
|
echo -e "${info}${stamp} -- [INFO] mySQLdump completed successfully --" \
|
||||||
|
"${normal}" >> "$logFile"
|
||||||
|
else
|
||||||
|
exitError+=("${stamp}_201")
|
||||||
|
fi
|
||||||
|
## verify the dump file was actually written to disk
|
||||||
checkExist fs "$sqlDumpDir/$sqlDumpFile"
|
checkExist fs "$sqlDumpDir/$sqlDumpFile"
|
||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "0" ]; then
|
if [ "$checkResult" = "0" ]; then
|
||||||
@ -585,14 +593,14 @@ checkExist fs "$sqlDumpDir/$sqlDumpFile"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
### Save redis state
|
### Save redis state
|
||||||
## Delete any existing redis dump file otherwise our check will be useless
|
## Delete any existing redis dump file otherwise our file check will be useless
|
||||||
echo -e "${op}${stamp} Cleaning up old redis state backup...${normal}" \
|
echo -e "${op}${stamp} Cleaning up old redis state backup...${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
checkExist ff "$dockerVolumeRedis/dump.rdb"
|
checkExist ff "$dockerVolumeRedis/dump.rdb"
|
||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "0" ]; then
|
if [ "$checkResult" = "0" ]; then
|
||||||
echo -e "${lit}${stamp} Old redis backup found.${normal}" >> "$logFile"
|
echo -e "${lit}${stamp} Old redis backup found. ${op}Deleting..." \
|
||||||
echo -e "${op}Deleting...${normal}" >> "$logFile"
|
"${normal}" >> "$logFile"
|
||||||
rm -f "$dockerVolumeRedis/dump.rdb" 2>> "$logFile"
|
rm -f "$dockerVolumeRedis/dump.rdb" 2>> "$logFile"
|
||||||
echo -e "${op}${stamp} ...done${normal}" >> "$logFile"
|
echo -e "${op}${stamp} ...done${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
@ -602,8 +610,15 @@ checkExist ff "$dockerVolumeRedis/dump.rdb"
|
|||||||
## Export redis
|
## Export redis
|
||||||
echo -e "${op}${stamp} Saving redis state information...${normal}" >> "$logFile"
|
echo -e "${op}${stamp} Saving redis state information...${normal}" >> "$logFile"
|
||||||
docker-compose exec redis-mailcow redis-cli save >> "$logFile" 2>&1
|
docker-compose exec redis-mailcow redis-cli save >> "$logFile" 2>&1
|
||||||
## although redis returns an 'OK' if successful, seemingly nothing can test for
|
saveResult=$(docker-compose exec -T redis-mailcow echo "$?")
|
||||||
## this... so let's just verify the dump file was written to disk
|
# verify save operation completed successfully
|
||||||
|
if [ "$saveResult" = "0" ]; then
|
||||||
|
echo -e "${info}${stamp} -- [INFO] redis save-state successful --" \
|
||||||
|
"${normal}" >> "$logFile"
|
||||||
|
else
|
||||||
|
exitError+=("${stamp}_202")
|
||||||
|
fi
|
||||||
|
## verify save-file written to disk
|
||||||
checkExist fs "$dockerVolumeRedis/dump.rdb"
|
checkExist fs "$dockerVolumeRedis/dump.rdb"
|
||||||
checkResult="$?"
|
checkResult="$?"
|
||||||
if [ "$checkResult" = "0" ]; then
|
if [ "$checkResult" = "0" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user