Question About Rsync and Modification Times

Kevin Korb kmk at sanitarium.net
Wed Oct 9 18:18:07 UTC 2024


You are using rsync -a which copies (preserves) the timestamp.  Meaning 
that rsync will copy the file then back-date it to the timestamp of the 
source file.  Most copying tools do not do this though cp's -a does it 
too.  Note that your itemized output says that the timestamp is 
different meaning that the file has changed since rsync last ran. 
Without the -a (or the included -t) the itemized output would have shown 
a 'T' instead of a 't' meaning "The timestamp is different and I'm not 
fixing it.".

If the file wasn't being modified the timestamp wouldn't be different 
and rsync would have just skipped it.

On 10/9/24 14:06, McDowell, Blake via rsync wrote:
> Hello,
> 
> I have a question about how/why rsync updates modification times, which 
> I haven’t been able to find an answer to.
> 
> I have two locally connected storage devices running TrueNAS Core: one 
> is new and empty, while the other is filled with files.
> 
> When I run the following rsync command:
> 
> /rsync -avPh --itemize-changes --stats "${@}"/
> 
> to transfer files from the full storage to the empty one, the 
> modification times of the transferred files are updated to the time of 
> transfer. I understand that using rsync to transfer to an empty storage 
> may not offer any real advantage, and that the modification times are 
> updated because rsync "touches" the files. However, I would prefer for 
> rsync not to update the modification times, though I gather this might 
> not be possible.
> 
> For context, the /--itemize-changes/ output during the initial transfer 
> looks like this:
> 
> />f++++++++++/
> 
> Now, if I wait for a minute and then run a dry run with the same command 
> on the files I just transferred, the output changes to:
> 
> />f..t......./
> 
> If I actually rerun the command, rsync updates the modification times to 
> the current time. This behavior repeats endlessly each time I run the 
> command.
> 
> Interestingly, if I manually "drag and drop" the files to the empty 
> storage, the modification times remain the same as the original files, 
> which is the outcome I prefer. Moreover, if I run the same rsync command 
> (/rsync -avPh --itemize-changes --stats "${@}"/) on the files that I 
> dragged and dropped, rsync doesn’t transfer or update any file, and the 
> /--itemize-changes/ output looks like this:
> 
> /.f/
> 
> I’m puzzled as to why rsync behaves differently for files initially 
> transferred using rsync versus those transferred via drag and drop. 
> Could this behavior be more related to TrueNAS rather than rsync?
> 
> Any clarification would be greatly appreciated.
> 
> Thanks,
> 
> Bleakley
> 
> 



More information about the rsync mailing list