From ca62d813688f3cacd9433717f58700226fd9eb0d Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 6 May 2020 23:54:31 -0600 Subject: [PATCH] dump sql --- .vscode/numbered-bookmarks.json | 2 +- backup/backup.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index 3fb6805..6bcb6f3 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -12,7 +12,7 @@ -1, -1, -1, - 582 + 599 ] } ] diff --git a/backup/backup.sh b/backup/backup.sh index 81eb9e4..e394919 100644 --- a/backup/backup.sh +++ b/backup/backup.sh @@ -596,6 +596,21 @@ else exitError 101 'Could not stop DOVECOT container.' fi + +### dump SQL +printf "%s[%s] -- [INFO] Dumping mailcow SQL database --%s\n" \ + "$cyan" "$(stamp)" "$norm" >> "$logFile" +docker-compose exec -T mysql-mailcow mysqldump --default-character-set=utf8mb4 \ + -u${DBUSER} -p${DBPASS} ${DBNAME} > "$sqlDumpDir/$sqlDumpFile" 2>> "$logFile" +dumpResult=$( docker-compose exec -T mysql-mailcow echo "$?" ) +if [ "$dumpResult" -eq 0 ]; then + printf "%s[%s] -- [INFO] SQL database dumped successfully --%s\n" \ + "cyan" "$(stamp)" "$norm" >> "$logFile" +else + exitError 119 'There was an error dumping the mailcow SQL database.' +fi + + ### execute borg depending on whether exclusions are defined ## construct the proper borg commandline @@ -706,6 +721,7 @@ exit 0 # 99: TERM signal trapped # 101: could not stop container(s) # 115: unable to create temp dir for SQL dump +# 119: error dumping SQL database # 130: null configuration variable in details file # 131: invalid configuration variable in details file # 138: borg exited with a critical error