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!

link|improve this question

75% accept rate
feedback

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.

link|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. – dwhsix Jan 14 at 16:59
It's ok. We are here to help each other. – Khaled Jan 14 at 17:43
feedback

Your Answer

 
or
required, but never shown

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