NYCPHP Meetup

NYPHP.org

[nycphp-talk] Re: can mysqldump exclude a database?

Dan Cech dcech at phpwerx.net
Thu Oct 28 23:34:28 EDT 2004


Here is a more elegant version:

mysql --password=mypass --batch --skip-column-names --execute="SHOW 
DATABASES" | grep -v "test" | xargs mysqldump --password=mypass 
--databases > nottest.sql

Dan

Dan Cech wrote:
> Faber Fedor wrote:
> 
>> On 28/10/04 22:57 -0400, Daniel Convissor wrote:
>>
>>> Hey Folks:
>>>
>>> mysqldump -A will export all of the databases.  But, what if I want 
>>> to exclude a particular database?  Is it possible?  How, please?
>>
>>
>> Is there a way to A) list all the databases (databasi?), B) run the
>> output through 'grep -v' and then C) mysqldump the result?
> 
> 
> Assuming your db password is mypass, and the database you want to 
> exclude is test, the following should do the trick:
> 
> mysql --password=mypass -B --skip-column-names -e'SHOW DATABASES' | grep 
> -v 'test' | xargs -n 1 "mysqldump" "--password=mypass" > nottest.sql
> 
> Dan
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org




More information about the talk mailing list