Tag Archives: shell

Pipe a gzipped mysql dump over ssh

I had a problem with a server without any space left on the drive, but still had to dump a database. So what i did was pipe the output of `mysqldump` to gzip and then send it over ssh to another server.

`mysqldump` outputs clear text so lets send that to gzip. We need to tell gzip to output the result to stdout so we can pipe it to ssh. We can do this by adding the -c option. Last we need to send it over ssh. You can pipe it over ssh by simply doing `ssh user@host ‘cat > ~/dump.sql.gz’

At the end you’ll end up with a string like this,

Toolbox

Ive created a bunch of nifty small bash scripts to do quick and dirty tasks for me when im in shell world. You can grap a copy of it right here and put them on your server or whatever.

importdb/exportdb = imports or exports a sql file to a database
deletesvn = removes all .svn folders from your current directory recursive
createrepo/deleterepo = creates and deletes a repository and setup a project structure with trunk, branch, and tags

toolbox.tar.gz