# .kopiaignore negation not working as expected

**URL:** <https://kopia.discourse.group/t/kopiaignore-negation-not-working-as-expected/3306>\
**Category:** Support\
**Created:** [September 28, 2024, 3:17am UTC](https://kopia.discourse.group/t/kopiaignore-negation-not-working-as-expected/3306 "2024-09-28T03:17:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Ericson](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/mark_ericson/32/1152_2.png) [@Mark\_Ericson](https://kopia.discourse.group/u/Mark_Ericson)\
**Post date:** [September 28, 2024, 3:17am UTC](https://kopia.discourse.group/t/kopiaignore-negation-not-working-as-expected/3306/1 "2024-09-28T03:17:57Z")

</div>

Given the following directory structure:

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

```

where parent/.kopiaignore contains:

```auto
/child3

```

and child3/.kopiaignore contains:

```auto
*
!grandchild1/
!grandchild2/

```

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Mark\_Ericson](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/mark_ericson/32/1152_2.png) [@Mark\_Ericson](https://kopia.discourse.group/u/Mark_Ericson)\
**Post date:** [October 5, 2024, 9:57pm UTC](https://kopia.discourse.group/t/kopiaignore-negation-not-working-as-expected/3306/2 "2024-10-05T21:57:43Z")

</div>

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

```auto
*
!grandchild1/
!grandchild2/

```

---

<div class="post-metadata">

**Author:** ![ingul-buz](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/ingul-buz/32/417_2.png) [@ingul-buz](https://kopia.discourse.group/u/ingul-buz)\
**Post date:** [October 6, 2024, 3:29pm UTC](https://kopia.discourse.group/t/kopiaignore-negation-not-working-as-expected/3306/3 "2024-10-06T15:29:08Z")

</div>

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

```auto
*/
!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).
