It guess I still haven't figured out the entire sematics of the --include
and --exclude options.  From reading the man page, it seems to say that
what happens is that each file being checked is tested against each pattern
in order, and when one matches the tests end, and whether it is --include
or --exclude determines if that file is included or excluded.

So I have on my server a big file tree.  I want to use rsync to download
only the PDF files, which make up a small portion of that tree.  So I try
it this way:

  rsync -aHPvz --include '*.pdf' --exclude '**' [EMAIL PROTECTED]:<source> 
<destination>

which gives me nothing.  For reference, I try:

  rsync -aHPvz --include '*.pdf' [EMAIL PROTECTED]:<source> <destination>

which starts downloading other files.  That confirms that the default final
action is equivalent to --include '**' or something like that.

So it seems the include pattern isn't matching.  So I try variations:

  rsync -aHPvz --include '*.pdf' --exclude '*' [EMAIL PROTECTED]:<source> <destination>
  rsync -aHPvz --include '**.pdf' --exclude '**' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '**.pdf' --exclude '*' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '**/*.pdf' --exclude '**' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '**/*.pdf' --exclude '*' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '/**.pdf' --exclude '**' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '/**.pdf' --exclude '*' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '/**/*.pdf' --exclude '**' [EMAIL PROTECTED]:<source> 
<destination>
  rsync -aHPvz --include '/**/*.pdf' --exclude '*' [EMAIL PROTECTED]:<source> 
<destination>

None of these work.

So finally, I replicate the file tree on the server with:

  cp -al <source> <alternatename>

And proceed to remove all non-PDF files:

  find <alternatename> -type f ! -name '*.pdf' -exec rm -f {} ';'

Then I do:

  rsync -aHPvz --include '*.pdf' --exclude '**' [EMAIL PROTECTED]:<alternatename> 
<destination>

which now works.

Can rsync do this by itself?  Is there a way to tell rsync "only download
this particular extension"?  How SHOULD I have done this?

I generally understand things best by knowing what sequence of steps is
performed.  I thought I understood this for rsync based on what the man
page said.  I guess one of us is wrong.

I'm running:  rsync  version 2.6.0  protocol version 27

-- 
-----------------------------------------------------------------------------
| Phil Howard KA9WGN       | http://linuxhomepage.com/      http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/   http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to