OK.  Let me just discard every single piece of quoted content from this
thread, because none of it makes ANY sense.

Here is what I see in the Subject: header:

1) Some piece of the verbose output of rsync, for unknown reason.
2) A question about how to do a specific task with rsync.

At some point the body of the thread mentioned an "error message" but
did not show one.  It also gave a code snippet with incredibly large
amounts of unnecessary obfuscation.  I'm going to ignore that.

As far as I can tell, the question is:

  "Given a directory hierarchy, I would like to rsync this hierarchy
  to a new location, but ignore all files except the ones ending with
  .foo and .bar"

Now let's see how to do that.  "man rsync" shows us the following options:

       --exclude=PATTERN        exclude files matching PATTERN
       --exclude-from=FILE      read exclude patterns from FILE
       --include=PATTERN        don't exclude files matching PATTERN
       --include-from=FILE      read include patterns from FILE

Most likely we'll want one or two of those.  Now let's set up a test.

unicorn:~$ mkdir /tmp/src && cd "$_"
unicorn:/tmp/src$ mkdir -p a/b/c a/b2
unicorn:/tmp/src$ touch a/b/c/good.foo a/b/c/bad.bad a/b2/good.bar a/b2/notgood
unicorn:/tmp/src$ find .
.
./a
./a/b2
./a/b2/good.bar
./a/b2/notgood
./a/b
./a/b/c
./a/b/c/good.foo
./a/b/c/bad.bad

And a destination directory:

unicorn:/tmp/src$ mkdir /tmp/dest

Now let's try the most obvious thing I can think of:

unicorn:/tmp/src$ rsync -a --include="*.foo" --include="*.bar" . /tmp/dest/
unicorn:/tmp/src$ find /tmp/dest
/tmp/dest
/tmp/dest/a
/tmp/dest/a/b2
/tmp/dest/a/b2/good.bar
/tmp/dest/a/b2/notgood
/tmp/dest/a/b
/tmp/dest/a/b/c
/tmp/dest/a/b/c/good.foo
/tmp/dest/a/b/c/bad.bad

All right, that didn't work.  Now let's try the second most obvious thing:

unicorn:/tmp/src$ rm -rf /tmp/dest
unicorn:/tmp/src$ mkdir /tmp/dest
unicorn:/tmp/src$ rsync -a --exclude="*" --include="*.foo" --include="*.bar" . 
/tmp/dest/
unicorn:/tmp/src$ find /tmp/dest
/tmp/dest

Hmm, that didn't work either.  Now it's time to read the documentation.

(read, read, read)

OK, here we go:

unicorn:/tmp/src$ rsync -a --include="*/" --include="*.foo" --include="*.bar" 
--exclude="*" . /tmp/dest/
unicorn:/tmp/src$ find /tmp/dest
/tmp/dest
/tmp/dest/a
/tmp/dest/a/b2
/tmp/dest/a/b2/good.bar
/tmp/dest/a/b
/tmp/dest/a/b/c
/tmp/dest/a/b/c/good.foo

There.  That's the desired result, if my interpretation of the Subject:
header is correct.

In order to understand it, you'll have to read the section titled
"INCLUDE/EXCLUDE PATTERN RULES" in the man page.  I won't repeat it
all here.

If there are additional questions, please try to ask them clearly.

Reply via email to