--include option

Wayne Davison wayned at users.sourceforge.net
Wed Aug 14 10:24:00 EST 2002

On Tue, 13 Aug 2002, Leaw, Chern Jian wrote:
> I tried your suggestion, but did not work. It still copied the entire
> filesystem across to the destination machine.

Since you failed to provide the command-line you're using, I can't tell
you exactly why your command failed.  For instance, if you use a
trailing slash on the sending-side directory you'd specify the
exclusions differently than if the slash was not there.

It's fairly easy to figure out for yourself what your inclusion &
exclusion lists should look like by first running the command with the
-n option (which tells rsync not to actually copy any files).  The names
that rsync outputs are the names you need to match (just add a slash to
the start of the name).  Once you get familiar with rsync you'll be able
to predict what these names will be, but until then, using -n lets you
ask rsync for the answer.  As a rule, all names specified before a slash
in the sending filename are eliminated from the name when matched
against the include/exclude names.

It is also sometimes useful to add an extra -v option to the command to
see what is getting included or excluded.

Another thing I recommend is that you use a "root slash" with names that
don't need to float to any level.  For instance, if you just specify
"foo" as an exclusion, it will exclude that directory OR file at any
point in the tree.  Specifying "/foo" (or "/sub/foo") is thus safer
since it protects against unintended matching.

I also prefer a single combined include/exclude file since it is easier
to edit and lets you order the inclusions and exclusions (remember that
the first matching pattern is the one that is acted upon, so sometimes
order does matter).  In a combined file, items that begin with "+ " are
always taken to be exclusions, and items that being with "- " are always
taken to be exclusions.  You can leave off the "+ " in an include file
(and the "- " in an excluded file), but I included both for completeness.

So, with a file named "myinc" that has these 3 lines in it:

+ /clock_speed
+ /fub_layout
- /*

using this command:

    rsync -avz --include-from=myinc /stor/circuit_design/

does not work for you, then I am misunderstanding something about your


More information about the rsync mailing list