If you pass rsync two local paths, it will default to using "--whole-file", and not delta-transfer. So, what you're looking for is "--no-whole-file". You also get delta-transfer if you requested '-c'.
Here's how you can verify:
$ mkdir a b
$ dd if=/dev/zero of=a/1 bs=1k count=64
$ dd if=/dev/zero of=a/2 bs=1k count=64
$ dd if=/dev/zero of=a/3 bs=1k count=64
$ rsync -av a/ b/
sending incremental file list
./
1
2
3
sent 196831 bytes received 72 bytes 393806.00 bytes/sec
total size is 196608 speedup is 1.00
Then touch a file and re-sync
$ touch a/1
$ rsync -av --inplace a/ b/
sending incremental file list
1
sent 65662 bytes received 31 bytes 131386.00 bytes/sec
total size is 196608 speedup is 2.99
You can verify it re-used the inode with "ls -li", but notice it sent a whole 64K bytes. Try again with --no-whole-file
$ touch a/1
$ rsync -av --inplace --no-whole-file a/ b/
sending incremental file list
1
sent 494 bytes received 595 bytes 2178.00 bytes/sec
total size is 196608 speedup is 180.54
Now you've only sent 494 bytes. You could use strace to further verify if any of the file was written, but this shows it at least used delta-transfer.
Note (see comments) that for local filesystems, --whole-file
is assumed (see the man page for rsync). On the other hand, across a network --no-whole-file
is assumed, so --inplace
on its own will behave as --inplace --no-whole-file
.
@PetrPudlák id does not "read" the file, this would be inefficient. It separates the files in chunks, applies a quick hash compares the hashes and transmits what's different. There is also a second more in depth comparision and the server keeps track of the chuncks, but it's not a real "reading" as in loading the whole thing into memory: https://rsync.samba.org/~tridge/phd_thesis.pdf
So, as Gunther Piez commented, it does know exactly what to copy.
How would it even know if it can avoid writing to the entire file? Doesn't it need to read the entire file first, to figure out what has changed? – user541686 – 2013-04-01T03:16:08.680
2@Mehrdad yes, it does, but reading the whole isn't a problem. If
rsync
reads the whole file and then seeks to and updates only those parts that are needed, btrfs will copy only these updated blocks. But ifrsync
reads and writes the whole file, then it'll be a problem. – Petr Pudlák – 2013-04-01T14:36:49.4472@Mehrdad
rsync
does not only know that it may avoid writing the entire file, it manages to do so without copying it completely over the net. Clever little program. – Gunther Piez – 2013-05-02T11:24:43.800