51

I use rsync to backup a directory which is very big, containing many sub-directories and files, so I don't want to see the "incremental file list". I just want to know the summary in the end. If I use the argument -q, nothing is output at all. Can I make rsync output only the summary?

Glorfindel
  • 1,213
  • 3
  • 15
  • 22
horsley
  • 513
  • 1
  • 4
  • 4

3 Answers3

89

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

rsync -a --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)
Bob Stein
  • 992
  • 1
  • 6
  • 9
  • 2
    This should be the accepted response. – nisc Aug 19 '21 at 00:59
  • 2
    Currently, this answer uses `-m`, but I don't see a need for it. The following should be minimally enough: `rsync -a --stats src/ dest/` – Abdull Feb 09 '22 at 17:21
  • 2
    ... also, a precondition to avoid the "file list" is NOT using the flags `-v` and `-P`. – Abdull Feb 09 '22 at 17:45
  • Although that's a good answer, it's not solving "...don't want to see the incremental file list..." part of the question. – csonuryilmaz Feb 14 '22 at 23:32
  • When we add previous answer's `sed` section to this solution, it's an accepted response. :) Thanks! :+1 – csonuryilmaz Feb 14 '22 at 23:35
  • 2
    @csonuryilmaz I didn't include it because I confess I don't understand sed very well, and it didn't work for me in cygwin/Win11 -- it only omitted the first line, which was "receiving incremental file list". Maybe it's an LF versus CRLF thing. – Bob Stein Feb 17 '22 at 20:44
  • 1
    @BobStein you're right. Sed implementation is a little bit different on other platforms. I couldn't use the same `sed` command between mac os and gnu/linux on a case. We should test `sed` part on various platforms. – csonuryilmaz Feb 18 '22 at 05:22
  • indeed `-m` means prune empty directories and makes zero sense to get included in this answer. – cregox May 13 '22 at 21:36
  • 1
    Thanks @cregox and @Abdull, I removed the `-m`. Still needs work on `sed` filters that work on multiple platforms. – Bob Stein May 15 '22 at 14:29
  • still need work on sed filters?! – cregox May 16 '22 at 08:52
  • @cregox, when I say "still needs work on sed filters" I mean that my answer might be improved by piping through a sed filter as [the other answer does](https://serverfault.com/a/526729/161152), but using a syntax that works well on Linux, Mac, Windows, etc. – Bob Stein May 26 '22 at 16:19
  • nah, i wouldn't bother with it. the summary stands good by itself! – cregox May 26 '22 at 17:32
18

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.

Marco
  • 1,489
  • 11
  • 15
2

Try this command

rsync -a --info=progress2 --stats source destination

Output

32,342,135  10%  134.45kB/s    0:03:54 (xfr#386, to-chk=1059/7326)
Acute X
  • 21
  • 1