Sunday, November 10, 2013

Compress and scp on the fly

tar cvfz - docs-dm  | ssh joseph@192.168.21.189 "tar zxvf -"

tar cfz - docs-dm  | ssh joseph@192.168.21.189 "tar zxvf -"

Step 1 :- Create a tar file that output to stdout
               tar cf -, the “-” is to output to stdout

Step 2 :- Pipe the output to an ssh connection that execute a command that read stdin and pass it to tar
          tar xvf -, where “-” is stdin.

------------------------------------------------------------------------------------------------
To change the directory and copy

tar cvf - portal-ho/  | ssh joseph@192.168.21.211 'cd /home/joseph/.  && tar xvf -';
 

No comments: