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