How to ignore directories?

I’ve read this : Issue with file/folder ignore rules - #5 by maclm

I try to ignore every folders named “.cache” but i don’t understand how the ignore policy work. Here are the policies of my repo :

  "files": {
    "ignore": [
      "**/.cache",
      "**/.cache/",
      "**/.cache/*",
      "**/.cache/**",
      "*/.cache",
      "*/.cache/",
      "*/.cache/*",
      "*/.cache/**",
      ".cache",
      ".cache/",
      ".cache/*",
      ".cache/**",
      "**/cache",
      "**/cache/",
      "**/cache/*",
      "**/cache/**",
      "*/cache",
      "*/cache/",
      "*/cache/*",
      "*/cache/**",
      "cache",
      "cache/",
      "cache/*",
      "cache/**"
    ],
    "ignoreDotFiles": [
      "**/.cache",
      "**/.cache/",
      "**/.cache/*",
      "**/.cache/**",
      "*/.cache",
      "*/.cache/",
      "*/.cache/*",
      "*/.cache/**",
      ".cache",
      ".cache/",
      ".cache/*",
      ".cache/**",
      "**/cache",
      "**/cache/",
      "**/cache/*",
      "**/cache/**",
      "*/cache",
      "*/cache/",
      "*/cache/*",
      "*/cache/**",
      "cache",
      "cache/",
      "cache/*",
      "cache/**"
    ]
  },

But when I run kopia snapshot estimate I still see that my “.cache” folder are backuped :

$ kopia snapshot estimate /home/me/
Analyzing ....
Analyzing .cache...
Analyzing .cache/pip...
Analyzing .cache/pip/http...
Analyzing .cache/pip/http/0...
[...]
Snapshots excludes no files.
Snapshots excludes no directories.

How to ignore a folder by its name ?

Oh i think i understand, i thought that global policies were common across all repositories and that the path you use at the end of “kopia policy set [opt] path” was the path of the repository you want to update.

But instead it looks like global policies are policies local to a repository, and the path is for creating policies for a specific folder inside a repository.

Or something like that, i’m not sure i understand how kopia works.

I think it should be sufficient to set a global policy which excludes .cache and cache.

kopia policy set --global --add-ignore .cache --add-ignore cache

If you only want to exclude caches under a specific directory do:

kopia policy set /path/to/some/dir --add-ignore .cache --add-ignore cache

All ignore rules are inherited from their parents and global is the ultimate parent. When you do that, it will look for .cache and cache when snapshotting any directory (under global, so all of them) and ignore them. In general there’s usually no need to mess with wildcards or “/”.

Thanks, after playing with it a bit I understand better how it works.