Can I make rsync output only the summary?

Solution 1:

Thanks to a tip by Wayne Davison, I use the --stats option for backup:

rsync -am --stats src/ dest/

Nice little summary at the end, e.g.

Number of files: 6765
Number of files transferred: 0
Total file size: 709674 bytes
Total transferred file size: 0 bytes
(10 more lines)

Solution 2:

Use the following:

rsync -vr src/ dest/ | sed '0,/^$/d'

Explanation: rsync is run in verbose mode using the -v flag. It outputs a detailed file list, an empty line and the summary. Now sed is used to take advantage of the fact that the summary is separated by an empty line. Everything up to the first empty line is not printed to stdout. ^$ matches an empty line and d prevents it from being output.