--compare-dest seems to nullify --update

Paul Gover pmw.gover at yahoo.co.uk
Fri Mar 26 17:52:21 UTC 2021

I'm  using rsync to update my local database snapshot from a remote pooled mirror server.  
The trouble is that the servers in the pool are sometimes out of date, so I only want to update 
when the files are newer than the local copies to avoid unnecessary I/O..

Originally I copied my existing database to a new directory, and updated that:
  cp -r <current> <new>
  rsync --update, <mirror> <new>
  mv <new> <current>
That worked fine, but then I noticed --inplace, and realized my copy to the new directory should 
be redundant.  So I tried:
  rsync --compare-dest=<current> --mkpath --update <mirror> <new>
  [ -e <new/stuff> ] && mv <new> <current>
Which appeared to work, except it sometimes get backdated!  My current hack is to change 
the second line to
  [ <new/stuff> -nt <current/stuff> ] && mv <new> <current>
but it's already wasted downloading the old stuff.

Exact reading of the docs says that --update compares source and target dates, so I guess it 
looks in the empty <new> rather than <current>.  I can see it's justified, but unexpected.

(For the curious, the snapshot is a Gentoo portage tree, about 75 MB in a single file, so it's 
worth trying to avoid unnecessary IO.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.samba.org/pipermail/rsync/attachments/20210326/0429ab4d/attachment.htm>

More information about the rsync mailing list