From bd36035a9f208bcdf9e515787a51a6e176e6bbd3 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Tue, 12 Jul 2022 12:34:26 -0600 Subject: [PATCH] refactor(compose): update container name lookup - filter by both compose v1 and v2 naming conventions --- backup/backup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backup/backup.sh b/backup/backup.sh index 7c28661..1c59788 100755 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -110,7 +110,7 @@ cleanup() { } doDocker() { - containerName="$(docker ps -a --format '{{ .Names }}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)" + containerName="$(docker ps -a --format '{{ .Names }}' --filter "name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1" --filter "name=${COMPOSE_PROJECT_NAME}-${2}-mailcow-1")" # determine action to take if [ "$1" = "stop" ]; then @@ -118,14 +118,14 @@ doDocker() { "$cyan" "$(stamp)" "$2" "$norm" >>"$logFile" ${dockerCmd} -f "$mcDockerCompose" stop --timeout "$dockerStopTimeout" "$2-mailcow" 2>>"$logFile" # set result vars - dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)" - dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' $containerName)" + dockerResultState="$(docker inspect -f '{{ .State.Running }}' "$containerName")" + dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' "$containerName")" elif [ "$1" = "start" ]; then printf "%s[%s] -- [INFO] Starting %s-mailcow container --%s\n" \ "$cyan" "$(stamp)" "$2" "$norm" >>"$logFile" ${dockerCmd} -f "$mcDockerCompose" start "$2-mailcow" 2>>"$logFile" # set result vars - dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)" + dockerResultState="$(docker inspect -f '{{ .State.Running }}' "$containerName")" fi }