Rsync - resending all files, because files have different timestamp (off by 1 second!)

5,588

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...

Enjoy

Share:
5,588

Related videos on Youtube

barrrista
Author by

barrrista

Updated on September 18, 2022

Comments

  • barrrista
    barrrista over 1 year

    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 (osx) 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).

  • barrrista
    barrrista almost 9 years
    Brilliant. --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).