How can i duplicate a directory on my server via ssh?

link|improve this question

60% accept rate
feedback

3 Answers

up vote 2 down vote accepted
cp -r directory_name destination
  -R, -r, --recursive
          copy directories recursively

... or maybe you want to exchange folders between hosts. Than you should use rsync

rsync -vaz --rsh="ssh -l username" ~/bk targetHost:~/test
link|improve this answer
you mean rsync -vaz ~/bk username@targetHost:~/test – Justin Feb 6 '10 at 20:39
feedback

You could do this with either rsync or scp, both of which go over ssh.

scp -rp directory remotehost:/path/to/directory

rsync -azv -e ssh directory/ remotehost:/path/to/directory
link|improve this answer
... and I forgot about scp. – Mad_Dud Feb 6 '10 at 17:50
feedback

tar also would be a candidate for this job:

tar cf - . | ssh user@host 'cd /$destination && tar xBf -'
link|improve this answer
While a little more complicated, tar is awesome for when you need the files to exactly match. I tend to use this for cloning filesystems or uncompressed backups. – Scott Pack Feb 6 '10 at 17:50
1  
using tar over ssh like that is also a number of times faster than scp or rsync when dealing with a lot of tiny files. – Justin Feb 6 '10 at 20:40
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.