How does rsync know which files to transfer

rsync

This is just a "I feel curious" question. When syncing locally (that is, from one drive to another on the same host), how does rsync know which files are not worth transmitting? I guess it does not do a full file compare (since that would be too expensive). Does it only do simple checking, like:

  • file size
  • modification time

If so, I guess it would be easy to fool rsync by changing the contents of the file, keeping the size, and resetting the modification time (if at all possible).

Best Answer

This is popular misconception - delta transfer with rsync. rsync was designed to do fastest copy, not necessary a delta copy. And to do delta copy you need to do checksums. Now, 'rsync' will NOT check which files to transmit but which files can be skipped. Usually will check on sender size/ mtime and compare with receiving end.

With rsync you have an option to do checksum on each file (I think that it's --checksum).Of course this will be slow...

Related Question