Allow 'borgmatic check' to run orphaned objects check without separate configuration file #779

Closed
opened 2023-10-29 10:15:54 +00:00 by jens-arnold · 8 comments

What I'd like to do and why

With borgmatic < version 1.8 it has been possible to check all archives in a repository, which makes "borg" check for orphaned objects. In order to do this, one would have specified prefix: "" in config section consistency:. With the new, flat configuration file format (and the prefix option being deprecated in borg) this is no longer possible.

Looking at the documentation, there is the new command line option --match-archives. Unfortunately this option is not supported for borgmatic check, but only for actions "info", "list", "rlist" and "transfer".

Next idea has been to use --override to override archive_name_format. Unfortunately this doesn't work either:

# borgmatic check --config XXXXX.yaml --override archive_name_format="" --only archives --force -v 1
XXXXX.yaml: No valid configuration files found

summary:
XXXXX.yaml: Error parsing configuration file
An error occurred while parsing a configuration file at XXXXX.yaml:
At 'archive_name_format': None is not of type 'string'
...

Next try...

# borgmatic check --config XXXXX.yaml --override archive_name_format="*" --only archives --force -v 1
XXXXX.yaml: No valid configuration files found

summary:
XXXXX.yaml: Error parsing configuration file
Invalid override 'archive_name_format=*': did not find expected alphabetic or numeric character
...

And another seemingly clever idea:

# borgmatic check --config XXXXX.yaml --override archive_name_format="{now}" --only archives --force -v 1
XXXXX.yaml: No valid configuration files found

summary:
XXXXX.yaml: Error parsing configuration file
An error occurred while parsing a configuration file at XXXXX.yaml:
At 'archive_name_format': {'now': None} is not of type 'string'

I did not test whether it works using an extra configuration file (it probably does, but it kinda misses the point of using borgmatic instead of naked borg).

Afaics there are two possible solutions to this problem:

  1. Make command line option --match_archives work for borgmatic check. Combined with the already implemented #734 --match_archives "*" should allow orphaned objects check
  2. Implement an additional options (e.g. --all-archives) which makes this behavior explicit.

Other notes / implementation ideas

No response

### What I'd like to do and why With borgmatic < version 1.8 it has been possible to check all archives in a repository, which makes "borg" check for orphaned objects. In order to do this, one would have specified `prefix: ""` in config section `consistency:`. With the new, flat configuration file format (and the prefix option being deprecated in borg) this is no longer possible. Looking at the documentation, there is the new command line option `--match-archives`. Unfortunately this option is not supported for `borgmatic check`, but only for actions "info", "list", "rlist" and "transfer". Next idea has been to use `--override` to override `archive_name_format`. Unfortunately this doesn't work either: ``` # borgmatic check --config XXXXX.yaml --override archive_name_format="" --only archives --force -v 1 XXXXX.yaml: No valid configuration files found summary: XXXXX.yaml: Error parsing configuration file An error occurred while parsing a configuration file at XXXXX.yaml: At 'archive_name_format': None is not of type 'string' ... ``` Next try... ``` # borgmatic check --config XXXXX.yaml --override archive_name_format="*" --only archives --force -v 1 XXXXX.yaml: No valid configuration files found summary: XXXXX.yaml: Error parsing configuration file Invalid override 'archive_name_format=*': did not find expected alphabetic or numeric character ... ``` And another seemingly clever idea: ``` # borgmatic check --config XXXXX.yaml --override archive_name_format="{now}" --only archives --force -v 1 XXXXX.yaml: No valid configuration files found summary: XXXXX.yaml: Error parsing configuration file An error occurred while parsing a configuration file at XXXXX.yaml: At 'archive_name_format': {'now': None} is not of type 'string' ``` I did not test whether it works using an extra configuration file (it probably does, but it kinda misses the point of using borgmatic instead of naked borg). Afaics there are two possible solutions to this problem: 1. Make command line option `--match_archives` work for `borgmatic check`. Combined with the already implemented #734 `--match_archives "*"` should allow orphaned objects check 2. Implement an additional options (e.g. `--all-archives`) which makes this behavior explicit. ### Other notes / implementation ideas _No response_
Owner

Thanks for filing this! There's no good reason why borgmatic check shouldn't have a --match-archives flag like some of the other actions do. Seems like an easy addition.

As for your various --override attempts, I think what's going on is that the value is (intentionally) getting parsed as JSON.. which unfortunately mean it's not easy to specify a Borg pattern there. So I'll also look into whether there's any way around that without losing the JSON functionality.

Thanks for filing this! There's no good reason why `borgmatic check` shouldn't have a `--match-archives` flag like some of the other actions do. Seems like an easy addition. As for your various `--override` attempts, I think what's going on is that the value is (intentionally) getting parsed as JSON.. which unfortunately mean it's not easy to specify a Borg pattern there. So I'll also look into whether there's any way around that without losing the JSON functionality.
Owner

I added a --match-archives flag to the check action in main, and it'll be part of the next release!

(Side note: Your ISP is currently bouncing notification emails from this server, so you may not be notified of this by email.)

I added a `--match-archives` flag to the `check` action in main, and it'll be part of the next release! (Side note: Your ISP is currently bouncing notification emails from this server, so you may not be notified of this by email.)
Owner

And I've fixed the override issue in main as well. So now if an --override is for an option with a string type, borgmatic won't try to parse those values as JSON/YAML and will just leave it as a plain string.

And I've fixed the override issue in main as well. So now if an `--override` is for an option with a string type, borgmatic won't try to parse those values as JSON/YAML and will just leave it as a plain string.
Owner

Done! (See comments above. You may not have received some comment notifications due to your ISP blocking them.)

Done! (See comments above. You may not have received some comment notifications due to your ISP blocking them.)
Owner

Just released with borgmatic 1.8.5!

Just released with borgmatic 1.8.5!
Owner

From amiconn on IRC:

Now that borgmatic >= 1.8.5 is finally available in Debian sid, I was able to test the new --match-archives option for "borgmatic check" as well as the fix for ---override and string parameters

Unfortunately neither --match-archives "*" nor --match archives "" enable the orphan check. The former matches all archives, but still causes borg to state "Orphaned objects check skipped (needs all archives checked)."

The latter works as if wasn't specified at all, i.e. it only matches archives as specified in the config file.

However, using --override it is possible to make borg check for orphans. --override archive_name_format="" doesn't do the trick, but both --override archive_name_format="*" and --override archive_name_format="{now}" do work.

From amiconn on IRC: > Now that borgmatic >= 1.8.5 is finally available in Debian sid, I was able to test the new --match-archives option for "borgmatic check" as well as the fix for ---override and string parameters > > Unfortunately neither --match-archives "*" nor --match archives "" enable the orphan check. The former matches all archives, but still causes borg to state "Orphaned objects check skipped (needs all archives checked)." > > The latter works as if wasn't specified at all, i.e. it only matches archives as specified in the config file. > > However, using --override it is possible to make borg check for orphans. --override archive_name_format="" doesn't do the trick, but both --override archive_name_format="*" and --override archive_name_format="{now}" do work.
witten reopened this issue 2024-04-03 01:26:15 +00:00
Owner

Re-fixed in main. It looks like Borg decides not to run the orphaned objects check when it receives --match-archives *, so I worked around that by not passing through --match-archives at all when the value is * or similar.

Re-fixed in main. It looks like Borg decides not to run the orphaned objects check when it receives `--match-archives *`, so I worked around that by not passing through `--match-archives` at all when the value is `*` or similar.
Owner

Released in 1.8.10!

Released in 1.8.10!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#779
No description provided.