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 destThe 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
1 Answer
I would use:
rsync -abviuzP src/ dest/-iturns on the itemized format, which shows more information than the default format-bmakes rsync backup files that exist in both folders, appending~to the old file. You can control this suffix with--suffix .suf-umakes rsync transfer skip files which are newer in dest than in src-zturns on compression, which is useful when transferring easily-compressible files over slow links-Pturns on--partialand--progress--partialmakes rsync keep partially transferred files if the transfer is interrupted--progressshows a progress bar for each transfer, useful if you transfer big files