Bug: rsync erroneously changes modification time

max.power at clovermail.net max.power at clovermail.net
Sun Jun 11 13:28:22 UTC 2017


When a file of same length already exists at the destination then the  
command 'rsync --archive --size-only' (--archive is same as -rlptgoD)  
may change the modification time of the destination file even if no  
modification was made.

Type the following commands in a terminal in order to reproduce the problem:

$ mkdir source
$ mkdir target
$ echo "file one" > source/file
$ echo "file two" > target/file
$ srcstamp=201111110000.11
$ tgtstamp=200001010000.00
$ touch -t $srcstamp source/file
$ touch -t $tgtstamp target/file
$ stat -c "%y %s" source/file
$ stat -c "%y %s" target/file

Notice, that although the file in source/ and target/ folder contain  
different content they do not  differ in size. Thus, there following  
command should not make any changes:

$ rsync -rlptgoD --size-only source/ target

There was indeed no backup performed, which can be verified by viewing  
the contents of the files:

$ cat source/file
$ cat target/file

However, the modification time of the target file was updated to the  
same modification time as file in source/:

$ stat -c "%y %s" source/file
$ stat -c "%y %s" target/file

Since the file was not modified the modification time should not be  
changed. Omitting the '-t' option in above rsync does not solve the  
problem because when a backup is actually performed then the  
modification time will simply be set to the current system time  
instead of the modification time of the source file.

The same behaviour can be observed when using the flags -rlptgoD (or  
--archive) with the --checksum flag. Although it is highly unlikely  
that the files will differ if the checksums are the same, the  
modficaition should still not be changed for consistency reasons.




-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  



More information about the rsync mailing list