Compare commits
3 Commits
3c5d766d0c
...
5af5a064a9
Author | SHA1 | Date | |
---|---|---|---|
|
5af5a064a9 | ||
|
9bd6c9d431 | ||
|
93a0cce519 |
@ -144,6 +144,15 @@ function checkExist {
|
|||||||
# not found
|
# not found
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
elif [ "$1" = "fs" ]; then
|
||||||
|
# find file > 0 bytes
|
||||||
|
if [ -s "$2" ]; then
|
||||||
|
# found
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
# not found
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
elif [ "$1" = "fd" ]; then
|
elif [ "$1" = "fd" ]; then
|
||||||
# find directory
|
# find directory
|
||||||
if [ -d "$2" ]; then
|
if [ -d "$2" ]; then
|
||||||
@ -556,22 +565,24 @@ 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 -u${DBUSER} -p${DBPASS} ${DBNAME} > "$sqlDumpDir/$sqlDumpFile" 2>> "$logFile"
|
||||||
checkResult=$(docker-compose exec -T mysql-mailcow echo $?)
|
## error checking sqldump within the container in a cron-friendly manner is a
|
||||||
# verify sql dump was successful
|
## nightmare, so let's just see if a non-empty file with the expected name was
|
||||||
if [ "$checkResult" = 0 ]; then
|
## created
|
||||||
echo -e "${ok}${stamp} -- [SUCCESS] SQL successfully dumped --${normal}" \
|
checkExist fs "$sqlDumpDir/$sqlDumpFile"
|
||||||
>> "$logFile"
|
checkResult="$?"
|
||||||
|
if [ "$checkResult" = "0" ]; then
|
||||||
|
echo -e "${ok}${stamp} -- [SUCCESS] SQL successfully dumped --" \
|
||||||
|
"${normal}" >> "$logFile"
|
||||||
else
|
else
|
||||||
exitError+=("${stamp}_201")
|
exitError+=("${stamp}_201")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
### Save redis state
|
### Save redis state
|
||||||
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
|
||||||
checkResult=$(docker-compose exec -T redis-mailcow echo "$?")
|
## redis outputs a simple 'OK' if the export succeeded, so check the log file
|
||||||
# Verify save was successful
|
## for a line just written that says that specifically
|
||||||
if [ "$checkResult" = 0 ]; then
|
if [ $(tail -1 "$logFile") = "OK" ];
|
||||||
echo -e "${ok}${stamp} -- [SUCCESS] redis state saved --${normal}" \
|
echo -e "${ok}${stamp} -- [SUCCESS] redis state saved --${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user