excluding based on filesystem?
Danny Sauer
rsync at danny.teleologic.net
Wed Jan 19 22:09:32 GMT 2005
Wayne wrote regarding 'Re: excluding based on filesystem?' on Wed, Jan 19 at 15:26:
> On Wed, Jan 19, 2005 at 10:44:42AM -0600, Danny Sauer wrote:
> > So, what I'm looking for is possibly a way to make excludes relative
> > to the root at the beginning of the operation - so that if I specify
> > "rsync --exclude /dev host:/ /backup/host", only /dev on host is
> > excluded, not /home/user/dev, etc.
>
> That is precicely what already happens. The only way it would exclude a
> "dev" further down in the transfer is for you to have specified "dev"
> instead of "/dev" -- the leading slash anchors the exclude at the base
> of the transfer.
The man page says
Note that, when using the --recursive (-r) option (which is
implied by -a), every subcomponent of every path is visited
from the top down, so include/exclude patterns get applied
recursively to each subcomponent.
Perhaps that should be amended to mention that this only happens when
the pattern doesn't start with a '/'? :) Or maybe I should just pay
more attention to the difference between transfer-base and file-base...
> There is a script that can generate an exclude list for you based on
> mount points. One version is attached to bug #1455, but I just checked
> in a slightly improved version into the "support" dir of the CVS source.
> You can see it here:
>
> http://rsync.samba.org/ftp/unpacked/rsync/support/mnt-excl
>
> It may not be quite what you want, but it would be easy to adapt its
I essentially did that (in my sh-based backup script):
BADDIRS=`ssh $HOST mount | \
perl -lane 'print $F[2] if $F[4] !~ /^(?:reiserfs|ext[23])$/'`
for DIR in $BADDIRS; do
ARGS="$ARGS --exclude \"$DIR\""
done
but I suppose generating a file rather than re-parsing mount's output
each time *would* be a bit more elegant. :)
> > Alternatively, is it possible to set up an rsync server on each of the
> > machines to be backed up, with the server excluding portions of the
> > directory tree?
>
> Sure, that's easy. See the "exclude" and "exclude from" directives
> in the rsyncd.conf file. These excludes are relative to the "path"
> specified for the module, so they affect every transfer no matter what
> subdir the user specifies for the source. They make the files vanish
> as far as the client is concerned, though, which affects --delete.
Cool. It may be better for me to go the server route anyway - I
imagine that'd be easier to manage with respect to per-host excludes.
That would be the behavior I want with respect to --delete, too.
Thanks a heap!
--Danny
More information about the rsync
mailing list