6

I am using rsync to backup files from my Mac laptop to a USB drive (exFAT) on my Windows laptop. The USB drive is shared within my home network, and mounted on my Mac.

I noticed a weird problem when rsync was resending all the files even though I had done nothing to modify them.

When I turned on --itemize-changes I can see that t was in the output for every file, indicating, that the file timestamps were the reason for resending.

>f..t.... netstat.txt

ls -lT (macOS) indicated a seconds formatted timestamp which showed one second difference between the file, with the source being newer.

$ ls -lT source/file.txt 
-rwxr-----  1 user  group  1176 Sep 19 22:32:59 2014 file.txt
$ ls -lT destination/file.txt 
-rwx------  1 user  group  1176 Sep 19 22:32:58 2014 file.txt

Adding the -c option to rsync ignored the timestamps difference, and skipped the unnecessary transfers. However, I would like to know why my source and target files have a timestamp difference of 1 second (as far as I bothered to check).

1 Answer 1

12

I know file systems can handle time differently, so this is likely the source of the discrepancy. You can adjust the threshold of the mod-time comparison with --modify-window.

# Ignore up to a 5 second difference. Tighten up as desired.
rsync --modify-window=5 do whatever...

More details can be found on the man page for Rsync.

--modify-window

When comparing two timestamps, rsync treats the timestamps as being equal if they differ by no more than the modify-window value. This is normally 0 (for an exact match), but you may find it useful to set this to a larger value in some situations. In particular, when transferring to or from an MS Windows FAT filesystem (which represents times with a 2-second resolution), --modify-window=1 is useful (allowing times to differ by up to 1 second).

1
  • Thank you. I tried --modify-window=30, and I got the same results. Then, I tried --modify-window=300, and again I got the same results. However, looking at the timestamps on each machine shows identical values. And this can't be a timezone problem, either, because most files that are identical are indeed properly treated as such during my rsync runs.
    – HippoMan
    Nov 5, 2022 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.