Last Updated: February 25, 2016
· stevenharman

SSH + gzip + pv + pipes = copying files from remote boxen

  1. SSH into a remote box and execute a command ssh "command"
  2. The "command" to execute dumps a file to std out cat my-app.sql, then compress that stream back to STDOUT | gzip -c
  3. Pipe the compressed stream through your local machine and get some stats and transfer status | pv
  4. Decompress the stream on the fly | gunzip
  5. Redirect the stream to a file on your local machine > tmp/my-app.sql

Putting it all together:

$ ssh "cat my-app.sql | gzip -c" | pv | gunzip > tmp/my-app.sql

Behold, UNIX!

1 Response
Add your response

Ooh, pv is cool. I was not previously aware of it, but here's a nice writeup with installation and stuff.

over 1 year ago ·