× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

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

Steven Harman
Jan 19, 2015
<ul> <li>SSH into a remote box and execute a command <code>ssh bob@some-server.example.com "command"</code></li> <li>The <code>"command"</code> to execute dumps a file to std out <code>cat my-app.sql</code>, then compress that stream back to STDOUT <code>| gzip -c</code></li> <li>Pipe the compressed stream through your local machine and get some stats and transfer status <code>| pv</code></li> <li>Decompress the stream on the fly <code>| gunzip</code></li> <li>Redirect the stream to a file on your local machine <code>&gt; tmp/my-app.sql</code></li> </ul> <p>Putting it all together:</p> <pre><code class="language-bash">$ ssh bob@some-sever.example.com "cat my-app.sql | gzip -c" | pv | gunzip &gt; tmp/my-app.sql</code></pre> <p>Behold, UNIX!</p>
comments powered by Disqus