.kopiaignore negation not working as expected

Given the following directory structure:

parent/
   .kopiaignore
   child1/
   child2/
     .kopiaignore
      grandchild1/
      grandchild2/
      grandchild3/
   child3/

where parent/.kopiaignore contains:

/child3

and child3/.kopiaignore contains:

*
!grandchild1/
!grandchild2/

When I run “kopia snapshot /parent” I would expect my snapshot to contain the following structure.

parent/
  .kopiaignore
   child1/
   child2/
      .koipaignore
      grandchild1/
      grandchild2/

However, child2 and its contents are not included in the snapshot.

p.s. this is a simplified illustration of what I am trying to achieve which is essentially exclude everything in a child directory except what I implicitly wish to include.

1 Like

Sorry, typo in original post, it is child2/.kopiaignore that contains:

*
!grandchild1/
!grandchild2/

It seems that child2/.kopiaignore should look like this:

*/
!grandchild1/
!grandchild2/

So, add a slash after the asterisk on the first line. I’m not sure why that’s needed, I’m not that familiar with .kopiaignore (or .gitignore) rule structure. But I suppose that’s the way to ignore all subdirectories, as it seems you still want to include the files in child2 itself (in this case the .kopiaignore file).