So, I'm writing a fairly nasy java app that needs to do some dumping
of mysql data from many remote sources.
I know I could do this internally with the mysql drivers for java,
but I feel it is faster, easier, and more reliable if I just drop out
to a shell and run mysqldump directly.
Now, the only tricky bit is that some of these dump files will be >
100 MB, so I need to perform the dump directly on the remote servers
so I don't lock up the database forever while the dump is transferred.
So, basic idea is to dump on remote servers, compress dump files,
slurp over to local machine, do stuff with the dumps.
As part of this, I want to use a where clause in my mysqldump.
According to the manpages for mysqldump, you have to include quotes
around your where clause. If you in turn want to use a string w/in
your where clause, you now have quotes within quotes. So far, n/p.
The tricky bit comes when you want to pass this whole thing to a
shell to fire via ssh. Then you get quotes within quotes within
quotes - which bash disallows.
So....
I have come up with a solution, but wanted to see if there was
something more elegant:
ssh -l username some_host_IP '/usr/bin/mysqldump -C -umysqlusername -
pmysqlpassword DBName TableName -w"SomeColumn like `echo -e "\047"`%
015`echo -e "\047"`" >> /tmp/dumpFromRemote1.sql'
ie, I use `echo -e "\047"` to get me a single quote where it needs to
be to satisfy mysql.
Is there something cleaner?
-- Kimball
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/