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?
Asked
Active
Viewed 6.2k times
61
Glorfindel
- 1,213
horsley
- 613
5 Answers
108
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
- 1,182
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,577
14
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
- 141
-1
You can run dry run, count files, and run it with pv command:
dry_run_output=$(rsync -avn --stats source/ destination/)
file_count=$(echo "$dry_run_output" | awk '/to-chk/ || /Number of created files/ {gsub(",", "", $5); print $5}')
rsync -avz --stats source/ destination/ | awk '/to-chk/ || /Number of created files/ {print}' | pv -l -s "$file_count"