Currently, I'm trying to copy the modified files between 2 folders, and want the files that have differences to be copied over to the new folder.

The folder structure is the following:

|-- update+old
|   |-- new
|   `-- pt
|       `-- abc
`-- web
    `-- abc

Quickly explaining:

update+old/new - Where the new files should be (--compare-dest)
update+old/pt/abc - The original files (destination)
web/abc - The files I've changed (source)

I'm running the command:

rsync -av "$PWD/web/abc/" "$PWD/update+old/pt/abc/" --compare-dest="$PWD/update+old/new/"

It is simply skipping over new and all the changes are being made to update+old/pt/abc/ directly, leaving update+old/new/ completelly empty.

I tried --dry-run (-n) but it doesn't give any information. (It used to say that update+old/new/ doesn't exist)

Am I doing something wrong or I misunderstood what is the use of the argument --compare-dest=?

In case it is needed, this is the output of rsync --version, running on Debian 8.6:

root@webtest:/var/www/c1s.int# rsync --version
rsync  version 3.1.1  protocol version 31
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

Which was installed a few hours ago by running apt-get install rsync.

  • Note the comments on the --whole-file option in the man page: "With this option rsync’s delta-transfer algorithm is not used and the whole file is sent as-is instead.... This is the default when both the source and destination are specified as local paths..." It is possible that this is interacting badly with the --compare-dest option. – user4556274 Dec 12 '16 at 16:26
  • @user4556274 I know what it was.... The directories are swapped. I should have update+old/new/ as the destination, instead of being on --compare-dest. – Ismael Miguel Dec 12 '16 at 16:43


The directories are swapped.

The command should be like this:

rsync -av "$PWD/web/abc/" "$PWD/update+old/new/" --compare-dest="$PWD/update+old/pt/abc/"

It still doesn't have the expected result (it just copies everything), but that is for another question.

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.