NYCPHP Meetup

NYPHP.org

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

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


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?
>>
>>I looked at the documentation and the --help output.  I'm hoping 
>>there's an undocumented option. :)
> 
> 
> Come to think of it, you could do this:
> 
> ls -al $mysql_dir  | grep ^d  | egrep -v '\.[\.]?' | grep -v $test | awk '{
> mysqldump $9 }' | sh
> 
> where $mysql_dir is the directory wherein your mysql databases reside
> and $test is the directory/database you don't want.
> 
> For those of you who don't read shell, the command line reads:
> 
> list all files in the mysql directory | show only the
> directories/databases | do not show the . and .. directories | don't
> show the $test directory/database | print out the statement "mysqldump
> directory" |  pass those strings to the shell for execution.
> 
> 
> Simple, no? :-)

It is if you speak shell, but the drawback is still that you execute 
mysqldump multiple times.  If you look at my previous email, I figured 
out a way to execute mysqldump only once to dump all of the required 
databases.

Dan



More information about the talk mailing list