Sunday, July 24

TAR/ZIPPED a folder to/from a remote server in one shot

Pull Method
--------------------------
TAR and ZIP a folder located on the destination server to local server

[root@linux1 work]# ssh root@linux2 "tar -cvf - /work/Speech" | gzip > Speech.tar.gz

[root@linux1 work]# ls -ltr
total 136624
-rw-r--r-- 1 root root 139753088 Jun 22 15:53 Speech.tar.gz
[root@linux1 work]#


PUSH Method
----------------------

Tar and zipped a local folder in cache and copy it on the destination server.

[root@linux2 work]# tar cvzf - Speech | ssh root@linux1 "cat > /root/Speech.tar.gz"

Check on the destination:

[root@linux1 work]# pwd
/root/work
[root@linux1 work]# ls -ltr
total 136624
-rw-r--r-- 1 root root 139755520 Jun 22 16:29 Speech.tar.gz
[root@linux1 work]#