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.

  • So in your first rsync, you're wanting to copy everything from /home/REPOS/.../Packages/ to the local folder updates. But exclude the copy for files that are found under /run/media/.../Packages/? Mar 26, 2015 at 22:13
  • Are you sure that unix.stackexchange.com/a/104265/100397 doesn't solve your question? Mar 26, 2015 at 22:46
  • @roaima That's correct.
    – orodbhen
    Mar 27, 2015 at 13:54
  • @roaima Yes, I tried the OPs method in that post, and it doesn't work. The time stamps are identical for all the common files between the two directories. Besides, it takes a very long time to compute all the checksums.
    – orodbhen
    Mar 27, 2015 at 14:24
  • what do you want to have? you have 3 dirs source, dest i compare. rsync --compare-desc will copy all files that was changed between source and compare and do not change anything in compare. Jun 12, 2017 at 7:13

3 Answers 3


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                   \

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


you need something like that: rsync --compare-dest=$local_repo/ $centos_repo/ $differences/ (define folders to variables or change variables to your paths, paths must be ended by /) $differences might be changed to current data or something like that.

It copy differences inside folders that was between centos_repo and local_repo (centos_repo is source) to differences folder. It make whole dirs tree but insert only changed files in differences.

If someone use it for backup, must remember that file which was deleted in source (centos_repo) and exist in compare (local_repo) is not copied to differences


rsync is not only inspecting content when deciding if files are "identical". For this to work correctly, you should sometimes use flags like "--no-times" (this oneworked for me in one occasion), or "--no-perms", "--no-owner", "--no-group, "--checksum", etc.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .