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

diff()patch-managementrsync

I'm copying lots of files that have changed from one server to another using rsync. I know I can use the -n option to do a dry run, so I can see what files have been changed. However is it possible to get rsync to print a diff of the file contents that's changed? I'd like to see what's happening before doing a copy? Something I can save to a file and the apply with diff(1) later?

Best Answer

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.