tar and untar over ssh

Any sys admin may come across a scenario in which he has to tar the files in one machine and untar them in another machine without staging the tar file in any of the machines.

Code:

[user1@host1 vish]$ hostname
host1.fiji.ad
[user1@host1 vish]$ pwd
/home/user1/vish
[user1@host1 vish]$ ls -ltr
total 148
-r-xr-xr-x 1 user1 users 8065 Aug 16 20:44 viversion.pl
-r-xr-xr-x 1 user1 users 12892 Aug 16 20:44 vidiscovery.pl
-r-xr-xr-x 1 user1 users 21629 Aug 16 20:44 fileaccess.pl
-r-xr-xr-x 1 user1 users 6071 Aug 16 20:44 extractlog.pl
-r-xr-xr-x 1 user1 users 10339 Aug 16 20:44 credstore_admin.pl
-r-xr-xr-x 1 user1 users 1228 Aug 16 20:44 connect.pl



These files can be pushed to another machine using tar instead of scp,rsync,etc... with following command.

Code:

[user1@host1 vish]$ tar cf - *|ssh user1@host2 'cd /tmp/loe;sudo -u root tar xfo -'

Comments

Popular posts from this blog

28 Names of Srimati Radha Rani (Hindi/Odia/English)