I'd like to transfer a directory between two servers, but compress the directory on the remote host before transfer, and then uncompress to another host. I'm sure it's possible to pipe everything all the way through and do it in a one liner.
I realise it would be better of course if I could transfer between the hosts directly but that would involve transferring keys and what not, and I love Unix one line power tools. I'm sure people can come up with a few different ways to do this. I'm looking for the shortest syntax and most bandwidth conservative.
To start off I have
ssh -n REMOTEHOST 'tar zcvf - DIRTOCOPY' | localZip.tar.gz
cat
with a(cd dest; tar xvzf -)
? – jw013 Aug 16 '12 at 14:16ssh -n host1 'tar cvzf - dir' | ssh -n host2 'cd dest; tar xvzf -'
? – jw013 Aug 16 '12 at 14:35rsync
about-z
option :Note that this option typically achieves better compression ratios than can be achieved by using a compressing remote shell or a compressing transport because it takes advantage of the implicit information in the matching data blocks that are not explicitly sent over the connection.
– rush Aug 16 '12 at 14:42