Mysql – Ran out of disk space, how to tar without creating copy

debiandisk-space-utilizationMySQLsqltar

I am at 98% of an 8GB SSD, and I have a 3 GB mysql data that I need to gzip and or tar and then download it, so then I can delete it.

How can I tar or gzip the sql (or the mysql tables) so that that I don't have to make a copy of the 3GB file and get disk full errors.

Running Debian 6.

Best Answer

Use the mysqldump utility to direct the file wherever you like:

mysqldump -A -u[username] -p[password] > /path/to/dest/backupname.sql

If you need to, you can pipe the output through gzip:

mysqldump -A -u[username] -p[password] | gzip -c > /path/to/dest/backupname.gz

Further, you can send the output from gzip to another server via ssh:

mysqldump -A -u[username] -p[password] | gzip -c | ssh user@192.168.0.1 'cat >  /path/to/dest/backupname.gz'