Exclude a dir except some subdirectories?

Is it possible to exclude to e.g. exclude everything in ~/.cache except a sub-directory or two (e.g. ~/.cache/a, ~/.cache/b)? I don’t want to hardcode a list of sub-directories to ignore which will need to be maintained (keep adding new sub-directories to ignore).

I looked at the examples in the docs but none seem to suggest this is possible or that rules have order/precedence to potentially allow for this like .gitignore-style.


Unrelated question: Regarding " kopia snapshot verify, the docs say:

This means that the command does not test whether blobs have been corrupted after they have been uploaded by Kopia, due to bit rot, bit flip, etc."

and that --verify-files-percent handles that by downloading (reading?) the files for errors. If the kopia repo is on a checksumming filesystem like btrfs/zfs, is that all handled by the filesystem natively implicitly by this feature of the filesystem or is there still reason to run --verify-files-percent? What this and automatic full maintenance cover that a checksumming filesystem wouldn’t? I am trying to squeeze every ounce of performance (time spent with backing up or maintenance) out of slow SMR drives that I have no other good use for.

here you are exclusion list which I use to exclude everything but some dirs:

.DS_Store
/*
!/Documents
!/Desktop
!/Library
/Library/*
!/Library/Thunderbird

It excludes .DS_Store files wherever they are, includes only /Documents, /Desktop and /Library/Thunderbird directories. Everything else is excluded.

Please note that all refers to the root of my snapshots. /Users/username in ma case.

It should give you an idea how to use it.

As for repo and ZFS I would not bother with --verify-files-percent as it will be covered by file system. Of course you should run ZFS scrub from time to time which would do exactly the same - verify all files for potential bit rot. Assuming you have some RAIDZ in place it will self heal transparently.

Full and short maintenance is still needed though - they do important repo housekeeping. The key task is to remove unused data (left behind when some snapshots are pruned). More details in docs.

1 Like