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.

Hoping this is the right place to ask this...

I have a directory tree like this:

r/a/src/etc...
r/a/target/etc...
r/a/xyz/etc...
r/b/src/etc...
r/b/target/etc...
r/c/src/etc...
r/c/target/etc...

Ideally, what I need to do is to get the target directories, and their contents, to a remote server, preserving the overall tree structure. Like:

r/a/target/etc...
r/b/target/etc...
r/c/target/etc...

If it's possible to do this with rsync exclude/include/filters, I'm baffled. I'm hoping it's possible, though, since otherwise it's a bit of a pain.

Suggestions?

Thanks!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

It should be simple using the following command:

$ rsync -aR r/*/target /destination

The /destination path can be local or on different machine. The -R option is important to preserve the tree structure. Only the target folders (with their contents) will be copied to /destination while preserving the tree structure.

share|improve this answer
    
Khaled - that's it; works like a charm. Not sure why I had so much trouble parsing the man page to figure it out. –  denishaskin Jan 14 '12 at 16:59
    
It's ok. We are here to help each other. –  Khaled Jan 14 '12 at 17:43
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.