Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

/
    my_work
               /dir1
                    keepdir1.ddd
                    keepdir2.ddd
                    file.cfg
                    (lots of files and directories I don't want)
               /dir2
                    (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*/*
- *

Update:

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
share|improve this question
    
What's the output if you run it with rsync -rvvl? –  SmallClanger May 2 '12 at 13:40
    
I updated the question with this. –  Greg_the_Ant May 2 '12 at 13:49
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.