2

rsync is said to use delta-transfer algorithm to transfer files.

For a preexisting destination file with the same filename as a source file,

  1. Is the delta-transfer algorithm used

    • only after rsync have decided to transfer the source file to the destination, or
    • during determining whether or not rsync will transfer the source file to the destination?
  2. When rsync has decided to transfer the source file to the destination file,

    Does the delta-transfer algorithm transfer the difference between the source and destination files?

    Does the delta-transfer algorithm work at the "sub-file" level, by first calculating the patch file between the two files, and then transferring the patch file to the destination, and then applying the patch file to the preexisting destination file to get an identical copy of the source file?

    If so, do rsync need to transfer the source file to the destination in order to calculate the patch file between the source and destination files? If yes, doesn't that contradict the purpose of the delta-transfer algorithm to avoid transferring the whole source file?

Thanks.

1 Answer 1

8

only after rsync have decided to transfer the source file to the destination

Yes.

during determining whether or not rsync will transfer the source file to the destination

No. Once rsync starts the delta algorithm, it is fully committed to updating the file.

Does the delta-transfer algorithm transfer the difference between the source and destination files?

By default, yes. You can disable it with the --whole-file option. Note that what is sent by the delta-transfer algorithm is not literally a diff of the two files.

Does the delta-transfer algorithm work at the "sub-file" level, by first calculating the patch file between the two files, and then transferring the patch file to the destination, and then applying the patch file to the preexisting destination file to get an identical copy of the source file?

No, because rsync does not assume that the sender has a copy of the destination's version of the file.

rsync uses rolling checksums to determine matching portions of the file without transferring the whole file in either direction. Of course, if there are no matches, the whole file will need to be sent.

3
  • Thanks. Is what is sent by the delta-transfer algorithm is part of the source file, i.e. subfile?
    – Tim
    Commented Jan 28, 2017 at 8:43
  • 1
    @Tim: rsync.samba.org/how-rsync-works.html Commented Jan 28, 2017 at 9:27
  • BTW, if doing a local sync (destination and source are on the same machine), rsync only transfers the entire file, rather than transferring deltas. You can override this with --no-W. (Note: all characters are lowercase, except the capital "W".) Commented Jan 1, 2023 at 0:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .