Need help with exclude

John Van Essen vanes002 at umn.edu
Tue Nov 25 18:41:32 EST 2003


On Tue, 25 Nov 2003, daniel <djoneill at gmx.net> wrote:
> Hi all,
> 
> I am having *massive* problems trying to exclude a single directory from an rsync.
> 
> I have serv1 and serv2.  I am trying to rsync /foo/test from serv1 to
> /foo on serv2   I want to exclude the directory /foo/test/dir1   So I try:
> 
> rsync -av --exclude-from=/foo/rsync.excludes /foo/test serv2:/foo
> 
> rsync.excludes contains:
> /foo/test/dir1/
> 
> 
> This is not working.

You are attempting to use an absolute path in the exclusion.

You want a relative path.  A leading "/" just anchors it to the base
of the tree for filename comparison (instead of floating it).

It looks like you figured that out later, though.

> I also try:
> 
> rsync -av --exclude=/foo/test/dir1/ /foo/test serv2:/foo
> 
> and the exclude still does not work.

Different syntax - same reason for failure.

> I have also tried other variations like:
> 
> rsync -av --exclude=/dir1/ /foo/test serv2:/foo
> 
> also to no avail.

This would have worked if you had specified the same paths for
the source and the destination.  You tried to take a shortcut by
not including 'test' in the destination and not using a trailing
slash in the source.

So now, the source root is "/foo/" (without the "test").
Therefore, the exclusion is trying to match "/foo/dir1/".

Either of these two commands should work - I recommend the 2nd:

rsync -av --exclude=/test/dir1/ /foo/test serv2:/foo
rsync -av --exclude=/dir1/ /foo/test/ serv2:/foo/test/

As a matter of habit and principle, I always specify the complete
paths down to the trailing / when I rsync two directories.  Then
there's never any confusion about what's going to happen.
-- 
        John Van Essen  Univ of MN Alumnus  <vanes002 at umn.edu>




More information about the rsync mailing list