Last Updated: February 25, 2016
·
10.01K
· stevenharman

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

  1. SSH into a remote box and execute a command ssh bob@some-server.example.com "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 bob@some-sever.example.com "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. http://www.catonmat.net/blog/unix-utilities-pipe-viewer/

over 1 year ago ·