Estimating backup usage with dir-merge filter

Benjamin R. Haskell rsync at
Thu Oct 6 14:01:47 MDT 2011

On Thu, 6 Oct 2011, Paul Dugas wrote:

> I appreciate the suggestions so far but I know how to measure usage 
> with 'du' et al. The hitch here is that I want to exclude files the 
> --filter='dir-merge .rsync-filter' excludes. Hense the thought to use 
> rsync itself.

It sounds like you missed the point of Kevin's message (in the other 
fork of this thread).  The point wasn't to use `du`, it was that you can 
run your stats against the backed-up files, not the source.  Then you're 
only running stats against the results of running the backup using the 
filters, so you don't need to filter them again.

If that doesn't make sense or isn't possible (backups are on some remote 
server), then just use your rsync command with '--list-only', and 
post-process that list.

E.g., if your command is:

rsync -a --filter='dir-merge .rsync-filter' /source /dest

It becomes, with a post-processing command that just counts bytes from 
files (not dirs/sockets/etc.): (all one command line -- munged for emailing)

rsync --list-only -a --filter='dir-merge .rsync-filter' /source /dest
| awk '/^-/ { total += $2 } END { print total }'

Post-processing is made simpler by the fact that rsync escapes "special" 
characters already.  (So, you don't have to worry about null bytes or 
newlines or anything in the filenames.)


More information about the rsync mailing list