Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have some folders that got duplicated by mistake and I have to merge them together. Let's say folder A contain file X and folder B contains file Y, I would like to get file X copied to folder B. But, of course, I can face more complex cases, where f.i. both folder A and B contain the same file X: in those cases, I would like to keep the newest copy of the file, so rsync should compare both files, and if the origin is older just skip, it otherwise the destination is the older one, overwrite.

Which parameters should I put on the rsync command line?

This is what I found googling, but I do not think is correct.

rsync -avz --ignore-existing src dest

The man page is somehow beyond me.

Thank you.

PS in those cases where a file exists in both folders, the better thing would be to overwrite the older one into the destination folder and at the same time keep a copy of the older, just as a backup in case you should get back to the previous

share|improve this question

1 Answer 1

up vote 16 down vote accepted

I would use:

rsync -abviuzP src/ dest/
  • -i turns on the itemized format, which shows more information than the default format
  • -b makes rsync backup files that exist in both folders, appending ~ to the old file. You can control this suffix with --suffix .suf
  • -u makes rsync transfer skip files which are newer in dest than in src
  • -z turns on compression, which is useful when transferring easily-compressible files over slow links
  • -P turns on --partial and --progress
  • --partial makes rsync keep partially transferred files if the transfer is interrupted
  • --progress shows a progress bar for each transfer, useful if you transfer big files
share|improve this answer
    
Thank you, that definitely does the trick! Have a nice day. –  Tiziano Solignani Feb 6 '13 at 14:10
    
Really nice, I ended up using rsync -abuP –  qed Jul 23 '13 at 9:24

Your Answer

 
discard

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

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