[PATCH] Add option --dirs-update (was: rsync -a --update resets status of newer target directories)

Arvid Requate requate at univention.de
Mon Jan 20 08:44:02 MST 2014


thanks for your comments. Attached you may find a git patch based on the master 
branch. The patch adds a new rsync option which helps in our use case of 
replicating Samba 4 sysvol directories. In this specific case fACLs, xattrs and 
modification timestamps of subfolders of the target can get modified by Windows 
client tools in between subsequent rsync runs. If this happens, they should 
not be overwritten to avoid inconsistencies and client side error messages.

To achive this, the patch implements an option "--dirs-update" to let rsync 
skip changes to directories in case the target directory has a more recent 
modification timestamp than the source directory *and* the direct content of 
the directories is the same. This option can be regarded as complementary to 
the existing option "--update", which does pretty much the same for files.
The patch also provides a script for the testsuite.

Maybe the patch is also useful for others. If it doesn't inflict any collateral 
damage on the general behaviour of rsync (e.g. the incremental recursion), 
maybe it would be worthwile to submit it as an enhancement bug to the 
bugzilla. Any opinions about this or suggestions for imrovement?

On 16.01.2014 01:31:38, Matthias Schniedermeyer wrote:
> - rsync doesn't determine if atime/mtime is bigger/smaller, it only
> determines if they are identical or not.

>From looking at the function cmp_time in util.c and its use in generator.c I 
obtained the impression that time ordering is explicitely considered. My patch 
makes use of this function. Also the description of the option "--update" in 
the manual page ("skip files that are newer") seems to support this impression.

I'm aware of the unidirectional nature of rsync you pointed out. We use rsync 
to let two machines pull the content of a certain directory tree and let them 
take turns at that. Modification time ordering is essential for this. Since 
Samba doesn't implement DFS replication yet we have to rely on this.


Dr. Arvid Requate
Open Source Software Engineer

Univention GmbH
be open.
28359 Bremen
Tel. : +49 421 22232-52
Fax : +49 421 22232-99

requate at univention.de

Geschäftsführer: Peter H. Ganten
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Additional-option-dirs-update.patch
Type: text/x-patch
Size: 9246 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/rsync/attachments/20140120/c549a2b2/attachment.bin>

More information about the rsync mailing list