Get rsync to generate a patch file instead of copying across files?

Solution 1:

There might be a better way, but this might work, albeit not that efficiently:

 rsync -vrn / dest:/ > ~/file_list

Then edit test to remove the stats, then:

while read file; do
    diff $file <(ssh dest "cat $file")
done < ~/edited_file_list

Another Option:
You might also consider mounting the file system with something like sshfs/fuse, and then just using diff.

Solution 2:

For create patch:

rsync -arv --only-write-batch=patch old/ new/

For apply it:

rsync -arv --read-batch=patch dir/

or use auto-generated script:

./patch.sh

Sources:

  • https://russt.me/2018/07/creating-and-applying-diffs-with-rsync/
  • https://www.comentum.com/rsync.html

Solution 3:

rsync can't do this natively, but if there's a possibility of using unison you can produce diff style format from that.

Tags:

Rsync

Diff

Patch