1

I try to use rsync with --include-from and --exclude-from options.

I have a directory structure like: /docs/domain-[a-z]/templates

Now I want to sync templates only if something is in there. Further do not want to sync anything like /docs/domain-a and /docs/domain-b if templates is empty.

I thought it would work if I exclude /docs/domain* and include **/templates but this is not working.

Should this work at all? Or is this just a problem of my rsync version 3.0.4 on SLES 11SP3

To clarify it

Source Dir

/docs/
/docs/anydomain/templates
/docs/anydomain/other
/docs/domain_blah/
/docs/domain_blah/tmp/
/docs/domain_blub/
/docs/domain_blub/tmp/
/docs/domain_blub/templates/anyfiles
/docs/domain_blob
/docs/ohter
/other

So I just want to sync the /domain_blub/templates if there is something inside templates and leave all the /docs/domain_blub/tmp and other files away But I too want to sync contents from /docs/anydomain/ or /docs/other and even /other

The target structure looks the same but there might be more domains set up which shouldn't be deleted or changed. It could look like this

/docs/
/docs/anydomain/templates
/docs/anydomain/other
/docs/domain_balah/
/docs/domain_balah/tmp/
/docs/domain_aaaa/
/docs/domain_aaaa/tmp/
/docs/domain_blah/
/docs/domain_blah/tmp/
/docs/domain_blub/
/docs/domain_blub/tmp/
/docs/domain_blub/templates/anyfiles
/docs/domain_blob
/docs/ohter
/other
jimmij
  • 46,064
  • 19
  • 123
  • 136
macbert
  • 143
  • 6
  • I'm not sure whether what you want to do can be done purely with rsync, or whether it needs a few shell commands to pave the way. You didn't provide enough information about what you're trying to do. What do your source and destination look like? – Gilles 'SO- stop being evil' Feb 05 '14 at 01:28
  • Does my clarification above help, or do you need more insights? – macbert Feb 05 '14 at 13:06
  • It's now clear, I voted to reopen. In the meantime, [this guide](http://unix.stackexchange.com/questions/2161/rsync-filter-copying-one-pattern-only/2503#2503) may help. Note that the order of exclude/include is important. – Gilles 'SO- stop being evil' Feb 05 '14 at 15:05

0 Answers0