Optional filter files

Matt McCutchen matt at mattmccutchen.net
Tue Oct 27 17:20:37 MDT 2009

On Tue, 2009-10-27 at 15:38 -0700, Jacob Weber wrote:
> Is it possible to call rsync and tell it to use a filter file if it  
> exists, but otherwise continue without errors?
> If I pass "--filter=. .rsync-filter", it will fail if .rsync-filter  
> doesn't exist.
> I know you can pass "--filter=: /.rsync-filter" to search for filter  
> files in each directory. That won't fail if there aren't any such  
> files. But I'm only interested in one file at the root.

No, rsync does not have such a feature.  It could be added, but I would
be skeptical of letting the filter support grow organically into
something unmanageable; I'd rather see it replaced with a full scripting
language once and for all.

For now, you can test for the filter file in the script calling rsync.
Here's the syntax for bash:

if [ -e .rsync-filter ]; then
	filter_opt=("--filter=. .rsync-filter")

rsync ... "${filter_opt[@]}" ...


More information about the rsync mailing list