Hi let's say I have a directory like this:

                    (lots of files and directories I don't want)
                    (same layout as dir 1)

So I want to copy the directory "my_work" and all of the "dir1", "dir2", etc sub directories. But within each of those I want to keep only certain files, and certain directories. In the directories I keep I want to recursively include everything.

Here's what I've tried so far but nothing seems to copy:

rsync -rl --include-from=~/rsync_include /my_work ~/backup

And the contents of rsync_include are:

+ *file.cfg
+ *keepdir*/*
- *


If I run with rsync -rvvl I get:

sending incremental file list
[sender] hiding directory my_work because of pattern *
delta-transmission disabled for local transfer or --whole-file
total: matches=0  hash_hits=0  false_alarms=0 data=0

sent 10 bytes  received 12 bytes  44.00 bytes/sec
total size is 0  speedup is 0.00
  • What's the output if you run it with rsync -rvvl? May 2, 2012 at 13:40
  • I updated the question with this. May 2, 2012 at 13:49

1 Answer 1


The final - * is ignoring everything that hasn't explicitly matched one of the preceding rules. This is what you want, but because the top level folders don't match, rsync won't even descend into them, so it won't have a chance to match the file patterns you've specified.

If you add:

+ my_work/
+ my_work/dir*

explicitly to the top of the file, then it should work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .