xelabs / go-mydumper

A multi-threaded MySQL backup and restore tool, faster than mysqldump
GNU General Public License v3.0
346 stars 100 forks source link

Allow regex to specify databases to dump #26

Closed fdellwing closed 4 years ago

fdellwing commented 4 years ago

In short, we need this: https://github.com/maxbube/mydumper#how-to-exclude-or-include-databases

Would be really cool to see it :)

BohuTANG commented 4 years ago

ACK, but there is no planned yet.

fdellwing commented 4 years ago

I thought some more over it and came to two possible implemantation ways:

a) Use the builtin REGEXP functionality. Sadly this lacks full support some important regexp features (https://linux.die.net/man/7/regex).

So

SHOW DATABASES WHERE `database` REGEXP '(^acc.*|foobar)';

will work but

SHOW DATABASES WHERE `database` REGEXP '^(?!(mysql\.|test\.))';

wont.

b) Filter the databases in go, this will somewhat work like the allTables function, but actually filtering the returned list.

I'm not that good in go, so I'm mostlikely not able to write this myself.

BohuTANG commented 4 years ago

It's simple in go to filter the database using regex rule. Here the problem is go-mydumer works under one database one time, so we need to change this first.

fdellwing commented 4 years ago

I'm working on implementing the multi database functionality, but it might take some time.

fdellwing commented 4 years ago

@BohuTANG I'm currently working on the implementation of regex support and have a small problem.

go does not support full PCRE syntax, so the regex that someone could use are limited. There are other libraries that provide PCRE support, but the are not GPL, so I cannot use them in this project, right?

BohuTANG commented 4 years ago

Yes.