# .kopiaigonre file to partly backup Windows NTFS file systems from Linux

**URL:** <https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519>\
**Category:** General Topics\
**Created:** [December 7, 2024, 8:09pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519 "2024-12-07T20:09:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![phunsoft](https://avatars.discourse-cdn.com/v4/letter/p/c2a13f/32.png) [@phunsoft](https://kopia.discourse.group/u/phunsoft)\
**Post date:** [December 7, 2024, 8:09pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/1 "2024-12-07T20:09:27Z")

</div>

The environment:

- Dualboot notebook: Linux Mint 21.3 and Windows 10
- Current system running: Linux (Mint 21.3)
- Windows NTFS partition (on same notebook) mounted at /win-c, and /win-d

I’m trying to setup kopia to backup parts of the NTFS partition mounted at /win-d with a policy to backup /, excluding everything but the wanted directories under /win-c. I’ve been trying .kopiaignore (llocated in the root /) with no success so far.

Say the file system structure looks lke this:  
`/`  
`+-- bin/`  
`+-- etc/`  
`...`  
`+-- win-d`  
` +-- Dont backup/`  
` | +-- some files`  
` +-- Backup this/`  
` | +-- some file`  
` | +-- anotherfile`  
` | +-- someDirectory/`  
` +-- @Backup2`

I tried with in .kopiaignore (in /)

`# exclude everything`  
`*`  
`# Include NTFS data`  
`!/win-d/Backup This/`  
`!/win-d/@Bachup2/`

But no success. I also tried adding \*, and \*_/_ to the “don’t exclude” lines.

How should the .kopiaignore look like?

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [December 7, 2024, 8:31pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/2 "2024-12-07T20:31:23Z")

</div>

```auto
/*

!/win-d
/win-d/*
!/win-d/Backup This
!/win-d/@Bachup2

```

---

<div class="post-metadata">

**Author:** ![phunsoft](https://avatars.discourse-cdn.com/v4/letter/p/c2a13f/32.png) [@phunsoft](https://kopia.discourse.group/u/phunsoft)\
**Post date:** [December 8, 2024, 7:32pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/3 "2024-12-08T19:32:09Z")

</div>

That doesn’t work. It still excludes everything.

Creating a new snapshot and clicking on “Estimate”, the summary line sais:  
`Total Bytes: 0 B (5.5 MB excluded) Files: 0 ( **19** excluded) Directories: 2 (61 excluded) Errors: 0 (0 ignored)`

Clicking at “ShoW Log” I can see all the Linux root level direcroties and the “Windows” second level directories in the list marked as “excluded”. Unfortunately, it doesn’t tell which are the two included directrories.

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [December 8, 2024, 7:53pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/4 "2024-12-08T19:53:35Z")

</div>

I have just tested and it works without any problem.

```auto
$ tree .
.
├── bin
├── etc
└── win-d
    ├── backup_this
    ├── backup_this_too
    └── do_not_backup

$ cat .kopiaignore
/*
!/win-d
/win-d/*
!/win-d/backup_this
!/win-d/backup_this_too

```

Now I backup this directory with kopia with and without `.kopiaignore`.

I mount repo (`kopia mount all /path/to/mount --webdav`) and here you are results:

snapshot without `.kopiaignore`:

```auto
$ tree 20241208-194044
20241208-194044
├── bin
├── etc
└── win-d
    ├── backup_this
    ├── backup_this_too
    └── do_not_backup

7 directories, 0 files

```

snapshot with `.kopiaignore`:

```auto
$ tree 20241208-194258
20241208-194258
└── win-d
    ├── backup_this
    └── backup_this_too

4 directories, 0 files

```

Make sure that your policies contain (`kopia policy show /path/of/snapshot/data`) `.kopiaignore`:  
Make sure that you do not limit your backup to single filesystem.

```auto
  Read ignore rules from files: inherited from (global)
    .kopiaignore
...
  Scan one filesystem only: false inherited from (global)

```

Otherwise I am not sure what you are doing wrong as you do not provide any details.

> [@phunsoft](#):
>
> Clicking at “ShoW Log” I can see all the Linux root level direcroties and the “Windows” second level directories in the list marked as “excluded”. Unfortunately, it doesn’t tell which are the two included directrories.

kopia does not have concept of `include`. Snapshot contains all data down from its root minus `excluded` items.

---

<div class="post-metadata">

**Author:** ![phunsoft](https://avatars.discourse-cdn.com/v4/letter/p/c2a13f/32.png) [@phunsoft](https://kopia.discourse.group/u/phunsoft)\
**Post date:** [December 9, 2024, 9:59am UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/5 "2024-12-09T09:59:35Z")

</div>

> [@kapitainsky](#):
>
> I have just tested and it works without any problem.

Thanks a lot for your time!  
I guess your `win-d` directory is _not_ the mount point of a NTFS file system mounted there, is it?

> [@kapitainsky](#):
>
> kopia does not have concept of `include`. Snapshot contains all data down from its root minus `excluded` items.

Yes, I understand this. I saw this in the log:

```auto
10:48:21.436 excluded dir var
10:48:21.436 Included files: None
10:48:21.437 Excluded files 10 KB ...100 KB: 1 files, total size 88.7 KB

```

The line _`Included file: None`_ is a bit confusing.

> [@kapitainsky](#):
>
> Make sure that your policies contain (`kopia policy show /path/of/snapshot/data`) `.kopiaignore`:  
> Make sure that you do not limit your backup to single filesystem.

Yes, I saw this. Here is what the `show policy`sais:

```auto
...
Files policy:
  Ignore cache directories: true inherited from (global)
  No ignore rules:
  Read ignore rules from files: inherited from (global)
    .kopiaignore
  Scan one filesystem only: false inherited from (global)
...

```

After all, my real structure is much too deep to be able to post here, so I just created a new directory `win-t` and some subdirectories, then copied some real files. Just to be able to have a something I can post lists here.

This is the structure of `/win-t`

```auto
$ tree /win-t
/win-t
├── 195_110.jpg
└── @Data
    ├── dont_backup
    │ ├── dira
    │ │ └── Mappe2.xlsx
    │ └── Mappe1.xlsx
    ├── dont_backup2
    │ └── Verbrauch_TG_ab_1995.xlsx
    ├── @eDokumente
    │ ├── 2up druck 2.pdf
    │ ├── 2up druck 3.pdf
    │ └── 2up druck.pdf
    ├── Gruppenfoto_Männerriege_2024_klein.jpg
    └── @Peter
        ├── Basisdaten_TG_ab_1995.pdf
        ├── Dir1
        │ ├── metanet-list-admin-error.png
        │ └── metanet-list-overview.png
        ├── dir2
        │ ├── metanet-list-overview.png
        │ └── _read_me.txt
        └── Information neues Zulassungsregime Fahrzeuge.pdf

```

and this is the `.kopiaignore` file:

```auto
$ cat /.kopiaignore
/*
!/win-t
/win-t/*
!/win-t/@Data/@eDokumente
!/win-t/@Peter

```

I really don’t see any difference to your test setup, except from some of the names starting with `@` in my environment. To be sure the `@`is not the problem, I renamed and removed all `@`with the same result: Noting gets backed up.

At least I can say it is not an issue with my real data being in an NTFS file system permanently mounted. Hmmmm…

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [December 9, 2024, 10:09am UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/6 "2024-12-09T10:09:53Z")

</div>

Ok. But now your dir structure is different than in your original example so obviously `.kopiaignore` structure has to be different too:)

You have additional sub level

```auto
/wit-t/@Data/backup-this
/wit-t/@Data/backup-this-not

```

vs. originally:

```auto
/wit-t/backup-this
/wit-t/backup-this-not

```

You have to allow data on every level:

```auto
/*
!/win-t
/win-t/*
!/win-t/@Data
/win-t/@Data/*
!/win-t/@Data/@eDokumente
!/win-t/@Data/@Peter

```

As when you exclude certain level nothing one level below can be “included/excluded” again (as it is invisible). So we have to bring it back to scope and then exclude everything else.

It is a bit confusing initially:) But run few experiments and hopefully you will see how it works.

And simple `include` option would make life so much easier in cases like this… But we have to work with what we have.

---

<div class="post-metadata">

**Author:** ![phunsoft](https://avatars.discourse-cdn.com/v4/letter/p/c2a13f/32.png) [@phunsoft](https://kopia.discourse.group/u/phunsoft)\
**Post date:** [December 9, 2024, 2:02pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/7 "2024-12-09T14:02:23Z")

</div>

> [@kapitainsky](#):
>
> Ok. But now your dir structure is different than in your original example so obviously `.kopiaignore` structure has to be different too:)

It is not really different, I just didn’t post every level. Didn’t expect this to be important (form exerience so far with the (windoes) backup tools I was using so far).

> [@kapitainsky](#):
>
> As when you exclude certain level nothing one level below can be “included/excluded” again (as it is invisible). So we have to bring it back to scope and then exclude everything else.
> 
> It is a bit confusing initially:)

It indeed is.

The paths to my data to be backed has undefined depth, i.e. I often create new subdirectories, and want they’ll be backed up without the need to think about modifying `.kopiaigonre` each time. I’d surely forget often, if I had to.

I’ll try to come up with the required `.kopiaignore` content.

In the docs about _Supported Patterns_ in `.kopiaignore`, I read:

```auto
* wildcard that matches any character zero or multiple times|
** Double `Wildcard` that matches zero or multiple directories|

```

What exactly is the difference? Since `*` matches _any character_ I was assuming this includes `/` and thus including one or more subdirectory levels, with, or without a filename at the end.

It now seems, `*` only matches any character **“between to slashes”** , i.e. either a single directory name or a file name, stopping at the next `/`.

So, would `**` help me out to keep my `.kopiaignore` simpler? If so, could you give me a starter?

Thanks again for your valuable help!

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://yyz2.discourse-cdn.com/free1/user_avatar/kopia.discourse.group/kapitainsky/32/535_2.png) [@kapitainsky](https://kopia.discourse.group/u/kapitainsky)\
**Post date:** [December 9, 2024, 2:39pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/8 "2024-12-09T14:39:19Z")

</div>

> [@phunsoft](#):
>
> What exactly is the difference? Since `*` matches _any character_ I was assuming this includes `/` and thus including one or more subdirectory levels, with, or without a filename at the end.

`*` does not match `/` I think

> [@phunsoft](#):
>
> So, would `**` help me out to keep my `.kopiaignore` simpler?

No idea:) depends on what you want to do.

> [@phunsoft](#):
>
> The paths to my data to be backed has undefined depth, i.e. I often create new subdirectories,

This is not an issue at all.

```auto
/*
!/win-t
/win-t/*
!/win-t/@Data
/win-t/@Data/*
!/win-t/@Data/@eDokumente
!/win-t/@Data/@Peter

```

will backup everything (with subfolders) in `/win-t/@Data/@eDokumente` and `/win-t/@Data/@Peter`.

Maybe it is yet another confusion:) When you define dir to backup (excluding other dirs at the same level) it contains all this dir content (files and dirs).

---

<div class="post-metadata">

**Author:** ![phunsoft](https://avatars.discourse-cdn.com/v4/letter/p/c2a13f/32.png) [@phunsoft](https://kopia.discourse.group/u/phunsoft)\
**Post date:** [December 9, 2024, 4:06pm UTC](https://kopia.discourse.group/t/kopiaigonre-file-to-partly-backup-windows-ntfs-file-systems-from-linux/3519/9 "2024-12-09T16:06:28Z")

</div>

I’m finally on my way. First two subdirs are selected for backup. I’m sure now, I’ll manage to include everything needed.

For the records, here is how my `.kopiaignore` looks like so far:

```auto

# Bring the /win-d directory back to scope, then exclude everything below it
# This makes all the directories at the /win-d/ level available for "do not exclude"
!/win-d
/win-d/*

# Bring the /win-d/@Data directory back to scope, then exclude everything below it
# This makes all the directories at the /win-d/@Data/ level available for "do not exclude"
!/win-d/@Data
/win-d/@Data/*

# Bring the /win-d/@Data/@Peter directory back to scope, then exclude everything below it
# This makes all the directories at the /win-d/@Data/@Peter level available for "do not exclude"
!/win-d/@Data/@Peter
/win-d/@Data/@Peter/*

# Now select the directories to "include" at the /win-d/@Data/@Peter/ level
!/win-d/@Data/@Peter/#-Documents
!/win-d/@Data/@Peter/#-Folders

```

Wow, is this fast! Incredibly fast.

Thanks again for bearing with me
