From b1e3d4c7f68fa612749ed4cf4d97fb871036ba6d Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Sun, 16 Mar 2025 12:56:47 +0200 Subject: [PATCH] update docs and comments to remove last vestiges of DB_NAMES Signed-off-by: Avi Deitcher --- README.md | 12 ++++++------ docs/backup.md | 8 ++++---- pkg/database/dump.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fc3b7a4d..698f5d66 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ __You should consider the [use of `--env-file=`](https://docs.docker.com/engine/ * `DB_PORT`: port to use to connect to database. Optional, defaults to `3306` * `DB_USER`: username for the database * `DB_PASS`: password for the database -* `DB_NAMES`: names of databases to restore separated by spaces. Required if `SINGLE_DATABASE=true`. -* `SINGLE_DATABASE`: If is set to `true`, `DB_NAMES` is required and must contain exactly one database name. Mysql command will then run with `--database=$DB_NAMES` flag. This avoids the need of `USE ;` statement, which is useful when restoring from a file saved with `SINGLE_DATABASE` set to `true`. +* `DB_DUMP_INCLUDE`: names of databases to restore separated by spaces. Required if `SINGLE_DATABASE=true`. +* `SINGLE_DATABASE`: If is set to `true`, `DB_DUMP_INCLUDE` is required and must contain exactly one database name. Mysql command will then run with `--database=$DB_DUMP_INCLUDE` flag. This avoids the need of `USE ;` statement, which is useful when restoring from a file saved with `SINGLE_DATABASE` set to `true`. * `DB_RESTORE_TARGET`: path to the actual restore file, which should be a compressed dump file. The target can be an absolute path, which should be volume mounted, an smb or S3 URL, similar to the target. * `DB_DUMP_DEBUG`: if `true`, dump copious outputs to the container logs while restoring. * To use the S3 driver `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_DEFAULT_REGION` will need to be defined. @@ -110,17 +110,17 @@ Examples: ### Restore specific databases If you have multiple schemas in your database, you can choose to restore only some of them. -To do this, you must restore using `DB_NAMES` to specify the schemas you want restored. +To do this, you must restore using `DB_DUMP_INCLUDE` to specify the schemas you want restored. When doing this, schemas will be restored with their original name. To restore under other names, you must use `SINGLE_DATABASE=true` on both dump and restore, and you can only do it one schema at a time. #### Examples: 1. Dump a multi-schemas database and restore only some of them: * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -v /local/path:/backup databack/mysql-backup dump ` - * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -e DB_RESTORE_TARGET=/backup/db_backup_201509271627.gz -e DB_NAMES="database1 database3" -v /local/path:/backup databack/mysql-backup restore` + * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -e DB_RESTORE_TARGET=/backup/db_backup_201509271627.gz -e DB_DUMP_INCLUDE="database1 database3" -v /local/path:/backup databack/mysql-backup restore` 2. Dump and restore a schema under a different name: - * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -e SINGLE_DATABASE=true -e DB_NAMES=database1 -v /local/path:/backup databack/mysql-backup dump` - * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -e DB_RESTORE_TARGET=/backup/db_backup_201509271627.gz -e SINGLE_DATABASE=true DB_NAMES=newdatabase1 -v /local/path:/backup databack/mysql-backup restore` + * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -e SINGLE_DATABASE=true -e DB_DUMP_INCLUDE=database1 -v /local/path:/backup databack/mysql-backup dump` + * `docker run -e DB_SERVER=gotodb.example.com -e DB_USER=user123 -e DB_PASS=pass123 -e DB_RESTORE_TARGET=/backup/db_backup_201509271627.gz -e SINGLE_DATABASE=true DB_DUMP_INCLUDE=newdatabase1 -v /local/path:/backup databack/mysql-backup restore` See [restore](./docs/restore.md) for a more detailed description of performing restores. diff --git a/docs/backup.md b/docs/backup.md index b88dfb55..587746f8 100644 --- a/docs/backup.md +++ b/docs/backup.md @@ -13,11 +13,11 @@ to a target. That target can be one of: By default, all databases in the database server are backed up, and the system databases named `information_schema`, `performance_schema`, `sys` and `mysql` are excluded. -For example, if you set `DB_NAMES_EXCLUDE=database1 db2` then these two databases will not be dumped. +For example, if you set `DB_DUMP_EXCLUDE=database1 db2` then these two databases will not be dumped. **Dumping just some databases** -* Environment variable: `DB_NAMES=db1,db2,db3` +* Environment variable: `DB_DUMP_INCLUDE=db1,db2,db3` * CLI flag: `--include=db1 --include=db2 --include=db3` * Config file: ```yaml @@ -30,7 +30,7 @@ dump: **Dumping all databases** -* Environment variable: `DB_NAMES=` +* Environment variable: `DB_DUMP_INCLUDE=` * CLI flag: `--include=` * Config file: ```yaml @@ -42,7 +42,7 @@ Note that you do not need to set those explicitly; these are the defaults for th **Dumping all databases except for one** -* Environment variable: `DB_NAMES_EXCLUDE=notme,notyou` +* Environment variable: `DB_DUMP_EXCLUDE=notme,notyou` * CLI flag: `--exclude=notme,notyou` * Config file: ```yaml diff --git a/pkg/database/dump.go b/pkg/database/dump.go index 8233c0b3..21059a90 100644 --- a/pkg/database/dump.go +++ b/pkg/database/dump.go @@ -22,7 +22,7 @@ func Dump(ctx context.Context, dbconn Connection, opts DumpOpts, writers []DumpW // all at once // mysqldump -A $MYSQLDUMP_OPTS // all at once limited to some databases - // mysqldump --databases $DB_NAMES $MYSQLDUMP_OPTS + // mysqldump --databases $DB_DUMP_INCLUDE $MYSQLDUMP_OPTS for _, writer := range writers { db, err := sql.Open("mysql", dbconn.MySQL()) if err != nil {