From 9e590bba0fb0ad57a652b0fffcc94a157b32d347 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sat, 20 Oct 2018 05:35:08 -0600 Subject: [PATCH] Container stop section using operateDocker function --- root/scripts/backup.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/root/scripts/backup.sh b/root/scripts/backup.sh index 46b7aeb..aec8992 100644 --- a/root/scripts/backup.sh +++ b/root/scripts/backup.sh @@ -187,11 +187,13 @@ if [ "$1" = "stop" ]; then >> "$logFile" docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \ >> "$logFile" + # verify dockerResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) elif [ "$1" = "start" ]; then echo -e "${op}${stamp} Starting ${2}-mailcow container...${normal}" \ >> "$logFile" docker-compose start ${2}-mailcow >> "$logFile" + # verify dockerResult=$(docker inspect -f '{{ .State.Running }}' ${COMPOSE_PROJECT_NAME}_${2}-mailcow_1) fi } @@ -480,14 +482,12 @@ fi ### Change directory to mailcowPath cd "$mailcowPath" + ### Stop postfix and dovecot so mailflow is stopped until backup is completed ## 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 -checkResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_postfix-mailcow_1) -if [ "$checkResult" -eq 0 ]; then +operateDocker stop postfix +# process result +if [ "$dockerResult" -eq 0 ]; then echo -e "${info}${stamp} -- [INFO] Postfix container stopped --${normal}" \ >> "$logFile" else @@ -496,12 +496,9 @@ else 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 -checkResult=$(docker inspect -f '{{ .State.ExitCode }}' ${COMPOSE_PROJECT_NAME}_dovecot-mailcow_1) -if [ "$checkResult" -eq 0 ]; then +operateDocker stop dovecot +# process result +if [ "$dockerResult" -eq 0 ]; then echo -e "${info}${stamp} -- [INFO] Dovecot container stopped --${normal}" \ >> "$logFile" else