<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="font-size:0.75em;">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..</span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Originally I copied my existing database to a new directory, and updated that:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  cp -r <current> <new></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  rsync --update, <mirror> <new></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  mv <new> <current></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">That worked fine, but then I noticed --inplace, and realized my copy to the new directory should be redundant.  So I tried:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  rsync --compare-dest=<current> --mkpath --update <mirror> <new></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  [ -e <new/stuff> ] && mv <new> <current></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Which appeared to work, except it sometimes get backdated!  My current hack is to change the second line to</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">  [ <new/stuff> -nt <current/stuff> ] && mv <new> <current></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">but it's already wasted downloading the old stuff.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">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.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><br /></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">(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.)</p>
</body>
</html>