Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do I copy an entire directory into a directory of the same name without replacing the content in the destination directory? (instead, I would like to add to the contents of the destination folder)

share|improve this question

migrated from stackoverflow.com Jun 2 '11 at 0:50

3 Answers

Use rsync, and pass -u if you want to only update files that are newer in the original directory, or --ignore-existing to skip all files that already exist in the destination.

rsync -au /local/directory/ host:/remote/directory/
rsync -a --ignore-existing /local/directory/ host:/remote/directory/

(Note the / on the source side: without it rsync would create /remote/directory/directory.)

share|improve this answer

scp will overwrite the files if you have write permissions to them.

In other words: You can make scp effectively skip said files by temporarily removing the write permissions on them (if you are the files' owner, that is).

share|improve this answer

Here:

rsync -azv -e ssh --delete --progress localdir/ user@remotehost:remotedir/

Note the trailing slashes — they're important.

(I have the first bit aliased to rsync-usual because I use it so often.)

share|improve this answer
4  
These options to rsync are exactly contrary to the requirements: --delete deletes all files in the destination that didn't exist in the source. – Gilles Jun 2 '11 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.