How rsync –compare-dest works

file-comparisonrsync

I know there's a very similar question here, but the accepted answer has nothing to do with rsync, and the OP's solution doesn't apply in my case.

I'm trying to get all the updates from a CentOS repo that differ from my local repo, by comparing them to a disk backup of the repo:

rsync -avh --dry-run --compare-dest=/run/media/user/centos6/updates/x86_64/Packages /home/REPOS/6/updates/x86_64/Packages/ updates

However, the dry-run shows that all packages will be transferred, not just the new ones.

Doing a different dry-run, as if I was copying from the repo to the disk, only transfers the new packages:

rsync -avh --dry-run /home/REPOS/6/updates/x86_64/Packages/ /run/media/djones/centos6/updates/x86_64/Packages

So rsync is clearly able to differentiate the new files, but for some reason the compare-dest option still doesn't seem to work.

The quick and dirty solution would be to simply dump a file list using the second command, and then feed that to rsync. But I'd really like to do this the "right" way.

Best Answer

I had the same trouble, you have to do:

rsync -avh --dry-run                                          \
      --compare-dest=/run/media/user/centos6/updates/x86_64/  \
      /home/REPOS/6/updates/x86_64/Packages                   \
      /path/to/updates

Note --compare-dest is the parent of Packages and do not put / at the end of source folder!

Related Question