You can make rsync print one line per file using -i and then use pv -l to report progress based on line count (in effect file count).
You will need pv (pipe viewer): http://www.ivarch.com/programs/pv.shtml
rsync -ai sourcedir/ targetdir/ | pv -l -s filecount > logfile
Use the following command to get file count:
find sourcedir | wc -l
Note: this command will show progress information based on number of files copied. This works best if there are many smallish files. If there are only a few files which are huge then you will not have much fun.
To see progress when you are updating (or comparing) an existing copy:
(more information: Compare directories but not content of files)
rsync -aii --delete sourcedir/ targetdir/ | pv -l -s filecount > logfile
The second -i makes rsync print one line per file even if they are equal.
Add -n to compare (not actually copy or delete anything).
Leave out --delete as needed.
This command will print to screen in real time the files that differ:
rsync -aii --delete sourcedir/ targetdir/ | pv -l -s filecount |
tee logfile | grep -v "^\."
The commands above work best when there are many smallish files. Here some workarounds if you have few huge files
Rsync has a built in progress report. See the rsync man page for -P or --progress or --info=progress2. I have not tested those much. Also those options will not work well with pv. Or at least I have not found out how.
Here is another crude workaround to see progress based on size:
- note the free space of target partition before copying using
df -h.
- note the size of the source dir using
du -sh.
- use
watch df -h on target and watch the size grow.
Obviosly this only works when copying and not when updating or comparing.