Knowledgebase

How to get copy of all mysql databases into individual tar.gz files?

Posted by mrzippy, 03-26-2009, 06:03 PM
Hello, I need some help.. I'm trying to use the "mysqldump" command to get a copy of all databases on the server... ... but I need each database to go into a "databaseXYZ.tar.gz" file. Does anyone know how to do this? So far, I can only get all the databases into a single file. But I need each database to have its own file. Thanks!

Posted by vapetrov, 03-26-2009, 06:56 PM
Something like #!/bin/bash for FF in `find /var/lib/mysql/ -type d -printf "%f\n"` do mysqldump $FF | gzip > $FF.sql.gz done Last edited by vapetrov; 03-26-2009 at 06:59 PM.

Posted by nwilkens, 03-26-2009, 08:09 PM
Auto MySQL Backup is a decent backup script, and it does what you describe.

Posted by transcend, 03-27-2009, 10:51 AM
Agreed, except I'd use: nice one-liner, and will handle unexpected characters/etc. in the dump, as well as getting the db names from mysql rather than the fs, which is probably a bit safer. Just my 2c.

Posted by mrzippy, 03-27-2009, 11:16 AM
Thanks! That worked great.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read


Language:

Client Login

Email

Password

Remember Me

Search