Skip to main content
4 of 4
Pipes implicitly continue line
Thor
  • 17.5k
  • 3
  • 55
  • 71

Similar to what jw013 suggested in the comments with separate compression/decompression steps, i.e. combine two ssh commands with a pipe:

compress=gzip decompress=gunzip ssh remote1 "cd srcdir; tar cf - dir | $compress" | ssh remote2 "cd destdir; $decompress | tar xvf -" 

Note that the compression/decompression is configurable without depending on the version of tar.

Update

You could also add checksum verification into the pipe:

compress=gzip decompress=gunzip ckprg=md5sum cksum=/tmp/cksum ssh remote1 "cd srcdir; tar cf - dir | $compress | tee <($ckprg > $cksum)" | ssh remote2 "cd destdir; tee <($ckprg > $cksum) | $decompress | tar xvf -" ssh remote1 cat $cksum ssh remote2 cat $cksum 
Thor
  • 17.5k
  • 3
  • 55
  • 71