From 5076cebc856446bb6f28bd3162fc5fc6ff93d3a1 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 20 Oct 2018 04:30:25 -0600 Subject: [PATCH] stop postfix and dovecot and error check --- root/scripts/backup.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/root/scripts/backup.sh b/root/scripts/backup.sh index 3bd88af..ce5112b 100644 --- a/root/scripts/backup.sh +++ b/root/scripts/backup.sh @@ -455,12 +455,34 @@ fi cd "$mailcowPath" ### Stop postfix and dovecot so mailflow is stopped until backup is completed -echo -e "${op}${stamp} Stopping postfix and dovecot containers now..." \ - "${normal}" >> "$logFile" -docker-compose stop --timeout ${dockerStopTimeout} 2>> "$logFile" -# docker-compose always returns an error code of 0, so there is no point in -# error checking -echo -e "${op}${stamp} ...done (verify in docker logs)${normal}" >> "$logFile" +## Stop postfix-mailcow container +echo -e "${op}${stamp} Stopping postfix-mailcow container...${normal}" \ + >> "$logFile" +docker-compose stop --timeout ${dockerStopTimeout} postfix-mailcow >> "$logFile" +# verify stop was successful +dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_postfix-mailcow_1 +if [ "$dockerResult" -eq 0 ]; then + echo -e "${info}${stamp} -- [INFO] Postfix container stopped --${normal}" \ + >> "$logFile" +else + exitError+=('101') + cleanup + quit +fi +## Stop dovecot-mailcow container +echo -e "${op}${stamp} Stopping dovecot-mailcow container...${normal}" \ + >> "$logFile" +docker-compose stop --timeout ${dockerStopTimeout} dovecot-mailcow >> "$logFile" +# verify stop was successful +dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_dovecot-mailcow_1 +if [ "$dockerResult" -eq 0 ]; then + echo -e "${info}${stamp} -- [INFO] Dovecot container stopped --${normal}" \ + >> "$logFile" +else + exitError+=('102') + cleanup + quit +fi ### Dump SQL