Recently had to dump a mysql database that was larger than the available space. Here’s a quick one-liner to compress the dump and pipe it over ssh to another destination.

# mysqldump DATABASE | gzip -c –fast |ssh ‘cat > /home/user/DATABASE.sql.gz’

One Response to “Pipe MySQL Dump Through SSH”
  1. Alex Brandt says:

    Or you can send it directly to mysql if you have a user on the remote system:

    `mysqldump | bzip2 | ssh ‘cat > bunzip2 | mysql -u -p’`

Leave a Reply