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.

P.S. 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


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
  • 2
    Really nice, I ended up using rsync -abuP – qed Jul 23 '13 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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