Skip to content

Commit

Permalink
applied change requests from deitch for PR 139
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanheinrichsen committed Dec 31, 2021
1 parent b03d6b4 commit 23edfbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ __You should consider the [use of `--env-file=`](https://docs.docker.com/engine/
* `DB_USER`: username for the database
* `DB_PASS`: password for the database
* `DB_NAMES`: names of databases to dump (separated by space); defaults to all databases in the database server
* `DB_NAMES_EXCLUDE`: names of databases (separated by space) to exclude from the dump; `information_schema`. `performance_schema`, `sys` and `mysql` are excluded by default. This only applies if `DB_DUMP_BY_SCHEMA` is set to `true`. For example, if you set `DB_NAMES_EXCLUDE=database1 db2` and `DB_DUMP_BY_SCHEMA=true` then theese two databases will not be dumped by mysqldump
* `DB_NAMES_EXCLUDE`: names of databases (separated by space) to exclude from the dump; `information_schema`. `performance_schema`, `sys` and `mysql` are excluded by default. This only applies if `DB_DUMP_BY_SCHEMA` is set to `true`. For example, if you set `DB_NAMES_EXCLUDE=database1 db2` and `DB_DUMP_BY_SCHEMA=true` then these two databases will not be dumped by mysqldump
* `SINGLE_DATABASE`: If is set to `true`, mysqldump command will run without `--databases` flag. This avoid `USE <database>;` statement which is useful for the cases in which you want to import the dumpfile into a database with a different name.
* `DB_DUMP_FREQ`: How often to do a dump, in minutes. Defaults to 1440 minutes, or once per day.
* `DB_DUMP_BEGIN`: What time to do the first dump. Defaults to immediate. Must be in one of two formats:
Expand Down
16 changes: 8 additions & 8 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ function do_dump() {
DB_NAMES=$(mysql -h $DB_SERVER -P $DB_PORT $DBUSER $DBPASS -N -e 'show databases')
[ $? -ne 0 ] && return 1
fi
if [[ -n "$DB_NAMES_EXCLUDE" ]]; then
# exclude databases if specificied
DB_NAMES_EXCLUDE=(`echo $DB_NAMES_EXCLUDE`)
else
# if not -> exclude the default ones
DB_NAMES_EXCLUDE=(information_schema performance_schema mysql sys)
if [ -z "$DB_NAMES_EXCLUDE" ]; then
DB_NAMES_EXCLUDE="information_schema performance_schema mysql sys"
fi
declare -A exclude_list
for i in $DB_NAMES_EXCLUDE; do
exclude_list[$i]="true"
done
for onedb in $DB_NAMES; do
if [[ " ${DB_NAMES_EXCLUDE[@]} " =~ " ${onedb} " ]]; then
# skip database if on exclude list
if [ -v exclude_list[$onedb] ]; then
# skip db if it is in the exclude list
continue
fi
$NICE_CMD mysqldump -h $DB_SERVER -P $DB_PORT $DBUSER $DBPASS --databases ${onedb} $MYSQLDUMP_OPTS > $workdir/${onedb}_${now}.sql
Expand Down

0 comments on commit 23edfbf

Please sign in to comment.