exclueding two directories

Wayne Davison wayned at samba.org
Wed Sep 14 05:34:34 GMT 2005


On Tue, Sep 13, 2005 at 08:01:10PM -0000, redlotus72 wrote:
> rsync -az -e ssh --delete $HOSTTOBACKUP:$SOURCE [...]
> I need to exclue the following:
> $HOSTTOBACKUP/Dir1
> and
> $HOSTTOBACKUP/Dir2

That all depends on what is in $SOURCE.  If its just a module name,
then  --exclude='/Dir[12]/'  will do the trick.  If there's also a
path that does not end in a trailing slash, then that directory name
will need to be prefixed as well.  Just follow this advice from the
man page:

    The easiest way to see what name you should filter is to just look
    at the output when using --verbose and put a /  in front of the name
    (use the --dry-run option if you're not yet ready to copy any
    files).

The trailing slash makes it apply to only a directory.  Your final
option is to use  --exclude='Dir[12]/'  which will exclude those
matching directories at any place in the hierarchy.  See the manpage
for full details.

..wayne..


More information about the rsync mailing list