diff --git a/docker/container.backup b/docker/container.backup index 8ec63cd..a7935b2 100755 --- a/docker/container.backup +++ b/docker/container.backup @@ -19,7 +19,7 @@ DEBUG=0 # Tests {{{ -# Expect at least 1 argument and 3 maximum {{{ +## Expect at least 1 argument and 3 maximum {{{ case $# in 1 ) ct_name="${1}" @@ -81,4 +81,16 @@ fi # }}} +# Get container service name {{{ +ct_service_name=$(find /etc/systemd -type f -iname "*${ct_name}*.service" -printf "%f\n") + +## If no specific systemd service exists, the docker.service will be used +if [ "${ct_service_name}" = "" ]; then + ct_service_name="docker.service" + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Service name — No specific service found for ${ct_name} container, the ${ct_service_name} will be stopped." +else + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Service name — Service name of the container to backup : ${ct_service_name} ." +fi +# }}} + exit 0