--include vs. --exclude
Phil Howard
phil-rsync-2 at ipal.net
Sat Apr 3 19:04:25 GMT 2004
On Sun, Mar 28, 2004 at 07:16:26PM -0600, John Van Essen wrote:
| On Fri, 26 Mar 2004, Phil Howard <phil-rsync-2 at ipal.net> wrote:
| >
| > 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 '**' user at host:<source> <destination>
| >
| > which gives me nothing.
|
| Hi Phil,
|
| Your goal seems to be to create a tree that consists only of *.pdf
| files and their necessary directory nodes. Right?
Right.
| The closest you can get to that with standard includes/excludes is
| with this combination:
|
| --include '*/' (process/create all directory nodes)
| --include '*.pdf' (include all *.pdf files)
| --exclude '*' (exclude everything else)
|
| The disadvantage is that you will get the entire tree, even the
| branches with no pdf files.
I was not including that first --include '*/' for the directories.
I was under the impression rsync simply created directories "as needed".
| rsync 2.6.0 has a new 'files-from' option which will do what you need,
| but you have to create the file list yourself (easy enough to do with
| the 'find' command). But you are at a disadvantage in that you are
| doing a pull and may not have access to the source.
|
| Here's a possibility. Do a --dry-run first to determine the names
| of the pdf files. Grep the -v output of rsync for '\.pdf$', store
| that list in a file, then do a real run with the files-from option.
|
| I didn't try this - so I haven't verified that this will work.
Maybe a feature like "--make-needed-directories" would do well. Of course
for directories that exist at the source, using the same metadata should
still be done.
--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
More information about the rsync
mailing list