Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get a dump of all my databases *except one* using mysqldump?

Tags:

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!

like image 497
Daniel Magliola Avatar asked May 26 '10 23:05

Daniel Magliola


People also ask

How do I dump all databases?

To dump entire databases, do not name any tables following db_name , or use the --databases or --all-databases option. To see a list of the options your version of mysqldump supports, issue the command mysqldump --help .

How do I dump multiple databases in MySQL?

To backup multiple MySQL databases with one command you need to use the --database option followed by the list of databases you want to backup. Each database name must be separated by space. The command above will create a dump file containing both databases.

What is the difference between Mysqldump and Mysqlpump?

mysqlpump is the 4th fastest followed closer by mydumper when using gzip. mysqldump is the classic old-school style to perform dumps and is the slowest of the four tools. In a server with more CPUs, the potential parallelism increases, giving even more advantage to the tools that can benefit from multiple threads.

Is Mysqldump capable of exporting a database?

There are three ways in which the mysqldump tool can be used: First, it can be used to export specific tables in a MySQL database. Second, it can be used to export databases. Third, it can be used to export an entire MySQL server.


1 Answers

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

like image 127
Ignacio Vazquez-Abrams Avatar answered Oct 20 '22 16:10

Ignacio Vazquez-Abrams