From 992f8ef16e1c5b037ec04bc7e74d43d6a0eb27e3 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 6 May 2020 23:38:26 -0600 Subject: [PATCH] stop containers before backup starts --- .vscode/numbered-bookmarks.json | 2 +- backup/backup.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index db3a033..3fb6805 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -12,7 +12,7 @@ -1, -1, -1, - 580 + 582 ] } ] diff --git a/backup/backup.sh b/backup/backup.sh index 35209e9..d905f3a 100644 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -580,6 +580,22 @@ if [ "$use503" -eq 1 ]; then fi +### stop postfix and dovecot mail containers to prevent mailflow during backup +doDocker stop postfix +if [ "$dockerResultState" = "false" ] && [ "$dockerResultExit" -eq 0 ]; then + printf "%s[%s] -- [INFO] POSTFIX container stopped --$s\n" \ + "$cyan" "$(stamp)" "$norm" >> "$logFile" +else + exitError 101 'Could not stop POSTFIX container.' +fi +doDocker stop dovecot +if [ "$dockerResultState" = "false" ] && [ "$dockerResultExit" -eq 0 ]; then + printf "%s[%s] -- [INFO] POSTFIX container stopped --$s\n" \ + "$cyan" "$(stamp)" "$norm" >> "$logFile" +else + exitError 101 'Could not stop DOVECOT container.' +fi + ### execute borg depending on whether exclusions are defined ## construct the proper borg commandline @@ -688,6 +704,7 @@ exit 0 # 2: not run as root # 3: borg not installed # 99: TERM signal trapped +# 101: could not stop container(s) # 115: unable to create temp dir for SQL dump # 130: null configuration variable in details file # 131: invalid configuration variable in details file