Count of files to be transferred

Matt McCutchen matt at mattmccutchen.net
Fri Apr 30 15:29:36 MDT 2010


On Fri, 2010-04-30 at 14:21 +0700, Ryan Joseph wrote:
> On Apr 30, 2010, at 12:54 PM, Matt McCutchen wrote:
> > Rsync determines which of the files in the file list need a data
> > transfer as it goes, so the only way to get the count in advance is to
> > do a separate dry run.  Then you could take the "Number of files
> > transferred" from --stats output.
> 
> What do you mean "dry run" and wouldn't that take as much time as the
> real backup thus effectively doubling the time? If so that's probably
> not a good option.

Rsync has a --dry-run option to run without actually making the changes
to the destination.  The source and destination are scanned as normal,
but transmission of the contents of files is skipped.  See the man page
for more information.

> > Alternatively, you could base the progress bar on the total number of
> > entries in the file list.  The --progress option does this, but it won't
> > be accurate if incremental recursion is enabled.
> 
> I tried the --progress option but it only seemed to show the progress
> for each file which really isn't helpful for my case. 

See the "to-check" values at the end of each progress line, for example:

$ rsync -r --progress src2/ dest2/
sending incremental file list
created directory dest2
./
filea
           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1/3)
fileb
           0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=0/3)

sent 126 bytes  received 53 bytes  358.00 bytes/sec
total size is 0  speedup is 0.00

Alternatively, if you use a development snapshot of rsync 3.1.0, the
--info=progress2 option will give a size and percentage that refer to
the entire set of source files, not the current file.

> How do I get the file list then? If I could read a list of files that
> will be transferred (rsync says it builds this list so it must be
> somewhere)

What rsync is "building" is the "file list", which contains /all/ source
files.  As I said, rsync determines as it goes which of those files need
a data transfer.

-- 
Matt



More information about the rsync mailing list