SSH + gzip + pv + pipes = copying files from remote boxen
- SSH into a remote box and execute a command
ssh bob@some-server.example.com "command" - The "
command" to execute dumps a file to std outcat my-app.sql, then compress that stream back to STDOUT| gzip -c - Pipe the compressed stream through your local machine and get some stats and transfer status
| pv - Decompress the stream on the fly
| gunzip - 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!
Written by Steven Harman
Related protips
1 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 ·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best #Ssh Authors
Sponsored by #native_company# — Learn More
#native_title# #native_desc#