views:

126

answers:

3

I'm currently using mySQLdump to backup my dev machine and servers.

There is one project I just started, however, that has a HUUUUUGE database that I don't really need backed up, and i'll be a big problem to add it to the rest of the backup cycle.

I'm currently doing this:

"c:\Program Files\mysql\MySQL Server 5.1\bin\mysqldump" -u root -pxxxxxx --all-databases > g:\backups\MySQL\mysqlbackup.sql

Is it possible to somehow specify "except this database(s)"?

I wouldn't like to have to specify the list of DBs manually, since that would mean that I'd have to remember updating my backup batch file every time I create a new DB, and I know that's not gonna happen.

EDIT: As you probably guessed from my command line above, i'm doing this on Windows, so I can't do any kind of fancy bash stuff, only wimpy .bat things.

Alternatively, if you have other ideas to solve this same issue, they are more than welcome, of course!

+2  A: 

mysql ... -N -e "show databases like '%';" |grep-v -F databaseidontwant |xargsmysqldump ... --databases > out.sql

Ignacio Vazquez-Abrams
Thanks for the answer. Unforunately, i'm on Windows, so I can't do that
Daniel Magliola
@Daniel: You *did* click on the links in the answer... right?
Ignacio Vazquez-Abrams
Duh, no, I didn't. Those didn't really look like links to me, at all. I blame the site's designer :-)Thanks for the asnwer!
Daniel Magliola
+1  A: 

Create a backup user and only grant that user access to the databases that you want to backup.

You still need to remember to explicitly grant the privileges but that can be done in the database and doesn't require a file to be edited.

Craig
thank you for that idea!The *remembering* part is the problem, though. Is it possible to give a user access to all databases by default, and only DENY access to some?That way, when creating a new DB, it'll get backup up, but I can choose explicitly some to skip.
Daniel Magliola
As far as I know you cannot default to allow access and then explicity deny access to certain databases.
Craig
+1  A: 

What about

--ignore-table=db_name.tbl_name

Do not dump the given table, which must be specified using both the database and table names. To ignore multiple tables, use this option multiple times.

Maybe you'll need to specify a few to completely ignore the big database.

J. Pablo Fernández
Maybe, but this DB has about 100 tables, that'll be a pain :-)Still the simplest idea, though, thanks!
Daniel Magliola
Are all the tables huge?
J. Pablo Fernández
Good point. But still, enough tables that it's a pain in the ass.
Daniel Magliola