Include and Exclude

Wayne Davison wayned at samba.org
Thu Dec 24 10:32:48 MST 2009


On Thu, Dec 24, 2009 at 05:50:22AM -0700, LuKreme wrote:
> rsync -avh --stats --password-file=/var/rsync.passwd --include=Maildir/ --exclude=* mail::root/usr/home /backup/usr/

That will send the Maildir directory (without any content) if that
directory exists in the root of the transfer.  If you want to send
things inside the Maildir, you need to either specify includes for
that information, or limit the excluding.  For instance, assuming
that the Maildir is in the root of the transfer, this is better:

    --include=/Maildir/ --exclude=/*

Since both are anchored, this includes this top-level dir, excludes
everything else in the top-level (root of the transfer), but does not
exclude the files that are in the included dir.  Another option:

    --include=/Maildir/*** --exclude=*

If your rsync is new enough to understand "***", that includes both
the dir and the contents, which overrides the global exclude.  If
your rsync is not new enough to understand "***", then you'd need a
separate include for the dir and the content:

    --include=/Maildir/ --include=/Maildir/** --exclude=*

The first method is the best when it is something this simple, but one
of the latter methods can be useful when doing something more complex.

..wayne..


More information about the rsync mailing list