Usually after dumping a MySQL database with mysqldump
command I immediately tar/gzip the resultant file. I'm looking for a way to do this in one command:
So from this:
mysqldump dbname -u root -p > dbname.sql
tar czvf dbname.sql.tgz dbname.sql
rm dbname.sql
To something like this:
mysqldump dbname -u root -p > some wizardry > dbname.sql.tgz
Or even better (since I'm usually scp'ing the dump file to another server):
mysqldump dbname -u root -p > send dbname.sql.tgz to user@host
I'm running bash on debian.
Best Answer
You can't use tar in a pipe like this, and you don't need it anyway, as you're only outputting a single file. tar is only useful if you have multiple files.