Skip to content

Commit 0419237

Browse files
author
AxelGuignard
committed
updated README and fixed condition
1 parent c6cf5a3 commit 0419237

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ __You should consider the [use of `--env-file=`](https://docs.docker.com/engine/
305305
* `DB_PORT`: port to use to connect to database. Optional, defaults to `3306`
306306
* `DB_USER`: username for the database
307307
* `DB_PASS`: password for the database
308-
* `DB_NAMES`: name of database to restore to. Required if `SINGLE_DATABASE=true`, otherwise has no effect. Although the name is plural, it must contain exactly one database name.
308+
* `DB_NAMES`: can be used in two distinct cases:
309+
* `SINGLE_DATABASE` has been set to `true`: in that case it specifies the name of the database to restore to, and it must contain exactly one database name.
310+
* `SINGLE_DATABASE` has not been set to `true` and `DB_DUMP_BY_SCHEMA=true` was used for backup: in that case it specifies which schemas to restore. It can contain one or more schema names separated with spaces.
309311
* `SINGLE_DATABASE`: If is set to `true`, `DB_NAMES` is required and mysql command will run with `--database=$DB_NAMES` flag. This avoids the need of `USE <database>;` statement, which is useful when restoring from a file saved with `SINGLE_DATABASE` set to `true`.
310312
* `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.
311313
* `RESTORE_OPTS`: A string of options to pass to `mysql` restore command, e.g. `--ssl-cert /certs/client-cert.pem --ssl-key /certs/client-key.pem` will run `mysql --ssl-cert /certs/client-cert.pem --ssl-key /certs/client-key.pem -h $DB_SERVER -P $DB_PORT $DBUSER $DBPASS $DBDATABASE`, default is empty ('')

entrypoint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ if [[ -n "$DB_RESTORE_TARGET" ]]; then
148148
RESTORE_OPTS=${RESTORE_OPTS:-}
149149
# If there are multiple schemas in the archive (e.g. DB_DUMP_BY_SCHEMA was used) and DB_NAMES is set,
150150
# restore only the required databases
151-
if [[ $(ls -1q $workdir/* | wc -l) -gt 1 ]] && [[ -n "$DB_NAMES" ]]; then
151+
if [ "$SINGLE_DATABASE" != "true" ] && [[ $(ls -1q $workdir/* | wc -l) -gt 1 ]] && [[ -n "$DB_NAMES" ]]; then
152152
for onedb in $DB_NAMES; do
153153
echo "Restoring $onedb from " $workdir/$onedb*
154154
# /!\ If a schema has a name that begins with another one, it will executed multiple times the other one

0 commit comments

Comments
 (0)