Rsync – Fix Resending All Files Due to Timestamp Differences

backuplinuxmacosrsyncwindows

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

Best Answer

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

Related Question