From cff595e6340c44ac53132dd4fed93872f85f0ca4 Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" Date: Sun, 8 Dec 2024 13:56:43 +0100 Subject: [PATCH] disable skip comments only when needed --- backup.sh | 8 +++++++- docker-compose.yaml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index d7db8a7..ead820e 100755 --- a/backup.sh +++ b/backup.sh @@ -29,7 +29,13 @@ do echo "==> Dumping database: $db" FILENAME=/backup/$DATE.$db.sql LATEST=/backup/latest.$db.sql - if mysqldump --single-transaction --skip-comments $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" + BASIC_OPTS="--single-transaction" + if [ -n "$REMOVE_DUPLICATES" ] + then + echo "WARNING: disabling comments in backup to remove deuplicate backups. Automatic database name detection won't work so set MYSQL_DATABASE on restore" + BASIC_OPTS="$BASIC_OPTS" --skip-comments + fi + if mysqldump $BASIC_OPTS $MYSQLDUMP_OPTS -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" $MYSQL_SSL_OPTS "$db" > "$FILENAME" then EXT= if [ -z "${USE_PLAIN_SQL}" ] diff --git a/docker-compose.yaml b/docker-compose.yaml index 5ac0e9d..64dcef0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -30,6 +30,7 @@ services: environment: - MYSQL_HOST=my_mariadb - MYSQL_USER=root + - MYSQL_DATABASE=${DATABASE_NAME} - MYSQL_PASS=${MARIADB_ROOT_PASSWORD} - MAX_BACKUPS=1 - INIT_BACKUP=1