quickshiftin / mysqlbkup

Lightweight MySQL backup script in BASH
GNU Lesser General Public License v3.0
157 stars 70 forks source link

Exclude certain db's #4

Closed bonelifer closed 9 years ago

bonelifer commented 10 years ago

One missing feature would be to be able to exclude certain db's, so that they are never backed up.

bonelifer commented 10 years ago

Specifically ignoring tables with a specific prefix.

amedee commented 9 years ago

It's simple enough to exclude certain databases. Just add a variable EXCLUDE_DB in the config section, which is a space separated list of database names. Then, as first line inside the for-loop where the backup script loops over the databases, add something like

[[ "$EXCLUDE_DB" =~ (^|[[:space:]])"$db"($|[[:space:]]) ]] && continue

The =~ operator checks if the item is in the list, and the continue command tells the for-loop to skip to the next database.

The actual code is left as an exercise to the reader.

amedee commented 9 years ago

Your other question, about excluding tables with a specific prefix, is a totally different beast, which should be a different issue. (And the answer will be: that is A LOT more work).

quickshiftin commented 9 years ago

Hi, please have a look at the master branch and v1.3 tag. I've added support for filtering of databases and a dry run mode. If there's any trouble with the new features please open a fresh issue here and I'll address it.