WIP: Check if directories exists

This commit is contained in:
Jeremy Gardais 2019-10-17 15:49:42 +02:00
parent 72b4db9a20
commit 5e66b3f93c
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 19 additions and 1 deletions

View File

@ -3,7 +3,7 @@
# Purpose {{{
## Backup data of a Docker container.
## To do that, the script will:
## Stop the corresponding container (or docker if no related service is found)
## Try to stop the corresponding container (or docker if no related service is found)
## Make a archive of the container's data to a backup path
## Clean old backup
## Restart the container service (or docker.service)
@ -60,6 +60,24 @@ esac
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Args management — Path to store the backup: ${docker_backup_path} ."
# }}}
## Ensure Docker data directory exists {{{
if [ ! -d "${docker_data_path}" ]; then
printf '\e[0;31m%-6s\e[m\n' "Docker data directory doesn't seems available: ${docker_data_path} ."
exit 1
fi
## }}}
## Ensure backup directory exists {{{
if [ ! -d "${docker_backup_path}" ]; then
printf '\e[0;31m%-6s\e[m\n' "Backup directory doesn't seems available: ${docker_backup_path} ."
exit 1
fi
## }}}
## Ensure container data directory exists {{{
if [ ! -d "${docker_data_path}/${ct_name}" ]; then
printf '\e[0;31m%-6s\e[m\n' "Container directory doesn't seems available: ${docker_data_path}/${ct_name} ."
exit 1
fi
## }}}
# }}}