`borg2`: Add `--exclude-archives`
- Dominant language
- Python
- Stars
- 13.7k
- Forks
- 875
- Avg merge
- 11h 15m
- Merged PRs (30d)
- 192
Description
Borg supports `--match-archives`, which allows selecting archives using various patterns, including archive name (default with exact or pattern matching), archive ID prefix (`aid:` pattern), archive tags (`tags:` pattern), archive creation time (`date:` pattern), etc. For an archive to be selected, it must match all given *inclusion* patterns.
Borg currently does not support the inversion of `--match-archives`, i.e., *exclusion* patterns for archives, similar to `--exclude` for paths. Having an equivalent mechanism for archives would make archive selection much more expressive while keeping the matching logic rather simple.
**Suggestion**
Add a new `--exclude-archives` option. The new option should accept the same archive matcher syntax as `--match-archives`, but instead exclude archives matching any of the given patterns. An archive should then be selected if it matches all patterns given with `--match-archives` and none of the patterns given with `--exclude-archives`.
For example:
```console
borg repo-list \
--match-archives "sh:my-machine-name-*" \
--exclude-archives "tags:test"
```
would list all archives whose name matches `my-machine-name-*`, except those tagged with `test`.
Likewise:
```console
borg delete \
--match-archives "tags:daily" \
--exclude-archives "tags:keep"
```
would delete all archives tagged with `daily`, except those additionally tagged with `keep`.
**Benefits**
This would
* make archive selection composable,
* avoid adding dedicated command-line options for every special filtering case,
* naturally complement the existing `--match-archives` mechanism,
* provide a flexible foundation for future archive matchers.
For example, together with the proposed extensions to the `date:` matcher discussed in #8715, `--older TIMESPAN` could eventually be deprecated in favour of `--exclude-archives "date:TIMESPAN/now"`
**Note**
The documentation currently does not explicitly state whether multiple `--match-archives` options are combined using `OR` or `AND` semantics. Documenting the matching semantics and evaluation order would be useful regardless of whether this proposal is accepted.
Contributor guide
Research direction
Start by tracing how --match-archives is handled by the repo-list and delete entry points, including how multiple matchers are combined. Check the existing option documentation and matching behavior first; done means --exclude-archives accepts the same matcher syntax, excludes archives matching any exclusion pattern, and the inclusion and exclusion semantics are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100