Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It’s more efficient to compress and copy the file and then
decompress it on the other end in one step. This time we use SSH, the secure protocol upon which SCP is based. Here’s
the command we execute on server1:
server1$ gzip -c /backup/mydb/mytable.MYD | ssh root@server2"gunzip -c - > /var/lib
>/mysql/mydb/mytable.MYD"
This usually performs much better than the first method, because
it significantly reduces disk I/O: the disk activity is reduced to
reading on server1 and writing on
server2. This lets the disk operate
sequentially.
You can also use SSH’s built-in compression to do this, but we’ve shown you how to compress and decompress with pipes because they give you more flexibility. For example, if you didn’t want to decompress the file on the other end, you wouldn’t want to use SSH compression.