Friday, June 27, 2008

tar Over ssh

On regular basis, we encounter the need to copy a whole directory between two hosts. Usually we do it when we clone oracle application software.
Each time I am looking for the right syntax … :( NO MORE !!!
tar cvf‎ – source_dir/ | ssh target_host "cd `pwd`;tar xvf‎ -"

This one will copy source_dir to‎ target_host
For slow connection‎:
tar cvf‎ – source_dir/ | gzip -c‎ | ssh target_host "cd `pwd`;gunzip -c|tar xvf‎ -"

You will enter password once‎ (probably‎)

1 comment:

doron said...

Hi ,

You can try this one as well:

tar cpf - . | (ssh user@host:/dest_dir ; tar xpf -) &


- doron