Quote:
Originally Posted by
nitinmathur18
Sorry, But i am not able to understand the code u suggested .
"# Run this on the local host, to log into username@host and create directories in /remote/path/$ENV/whatever
ssh username@host mkdir "'/remote/path/$ENV/whatever'" ';' tar -C "'/remote/path/$ENV/whatever'" -xf - < ~/file.tar"
It runs two commands on the remote server.
1) mkdir /remote/path/$ENV/whatever
2) tar -C /remote/path/$ENV/whatever -xf - < ~/file.tar
They are separated by ';', which will be fed into the other end as simply
;, as a separator between two shell statements. If you didn't put quotes around it, your shell would attempt to run
tar on localhost instead of feeding the command into ssh...
The 1) command creates the base directory you want.
The 2) command extracts the tarball you made, of all the subdirectories with the permissions you wanted, inside /remote/path/$ENV/whatever. It reads from standard input.
~/file.tar, a file on the
local host(not the remote host!), is the tarball I showed you how to create before. It is redirected into the standard input of ssh, so
tar on the other end can read it from its own standard input without having to keep the file on the remote host.
All you have to do is substitute your own variables and filename into it, then run it
locally.