From 604d3da07defbf877716965fe272ad47856ea9e1 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 6 May 2020 22:15:55 -0600 Subject: [PATCH] add mc params, defaults and pre-req checks --- .vscode/numbered-bookmarks.json | 18 ++++++++- backup/backup.sh | 67 ++++++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 4c08963..03ed6a9 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -1,3 +1,19 @@ { - "bookmarks": [] + "bookmarks": [ + { + "fsPath": "$ROOTPATH$/backup/backup.sh", + "bookmarks": [ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 352 + ] + } + ] } \ No newline at end of file diff --git a/backup/backup.sh b/backup/backup.sh index b044c29..e78629e 100644 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -199,6 +199,12 @@ err503Path="$scriptPath/503_backup.html" err503File="${err503Path##*/}" webroot="/usr/share/nginx/html" +# mailcow/docker related +mcConfig='/opt/mailcow-dockerized/mailcow.conf' +mcDockerCompose="${mcConfig}/docker-compose.yml" +dockerStartTimeout=180 +dockerStopTimeout=120 + ### process startup parameters while [ $# -gt 0 ]; do @@ -217,11 +223,6 @@ while [ $# -gt 0 ]; do badParam empty "$@" fi ;; - -v|--verbose) - # set verbose logging from borg - borgCreateParams='--list --stats' - borgPruneParams='--list' - ;; -c|--config|--details) # location of config details file if [ -n "$2" ]; then @@ -235,6 +236,11 @@ while [ $# -gt 0 ]; do badParam empty "$@" fi ;; + -v|--verbose) + # set verbose logging from borg + borgCreateParams='--list --stats' + borgPruneParams='--list' + ;; -5|--use-503) # enable copying 503 error page to webroot use503=1 @@ -266,6 +272,46 @@ while [ $# -gt 0 ]; do badParam empty "$@" fi ;; + -d|--docker-compose) + # path to mailcow docker-compose file + if [ -n "$2" ]; then + if [ -f "$2" ]; then + mcDockerCompose="${2%/}" + shift + else + badParam dne "$@" + fi + else + badParam empty "$@" + fi + ;; + -m|--mailcow-config) + # path to mailcow configuration file + if [ -n "$2" ]; then + if [ -f "$2" ]; then + mcConfig="${2%/}" + shift + else + badParam dne "$@" + fi + else + badParam empty "$@" + fi + ;; + -t1|--timeout-start) + if [ -z "$2" ]; then + badParam empty "$@" + else + dockerStartTimeout = "$2" + fi + ;; + -t2|--timeout-stop) + if [ -z "$2" ]; then + badParam empty "$@" + else + dockerStopTimeout = "$2" + fi + ;; *) printf "\n%sUnknown option: %s\n" "$err" "$1" printf "%sUse '--help' for valid options.%s\n\n" "$cyan" "$norm" @@ -299,6 +345,17 @@ if [ "$use503" -eq 1 ]; then badParam dne "(--webroot default)" "$webroot" fi fi +# verify mailcow.conf location and extract path +if [ -f "$mcConfig" ]; then + # strip filename and get path + mcPath=${mcConfig%/*/} +else + badParam dne "(--mailcow-config)" "$mcConfig" +fi +# verify docker-compose file exists +if [ ! -f "$mcDockerCompose" ]; then + badParam dne "(--docker-compose)" "$mcDockerCompose" +fi ### start logging