borgmatic seems to be confused re --glob-archives and --match-archives #666

Closed
opened 2023-04-04 01:52:26 +00:00 by lingfish ยท 9 comments

What I'm trying to do and why

Trying to run borgmatic info with the -a argument.

Steps to reproduce (if a bug)

Run borgmatic -v2 -c /etc/borgmatic/config.yaml info -a '*a*'

Actual behavior (if a bug)

Ensuring legacy configuration is upgraded
borg --version --debug --show-rc
/etc/borgmatic/config.yaml: No commands to run for pre-actions hook
ssh://host/./NAS: Displaying archive summary information
borg info --debug --show-rc --match-archives *a* ssh://host/./NAS
usage: borg [-V] [-h] [--critical] [--error] [--warning] [--info] [--debug]
            [--debug-topic TOPIC] [-p] [--iec] [--log-json]
            [--lock-wait SECONDS] [--bypass-lock] [--show-version] [--show-rc]
            [--umask M] [--remote-path PATH] [--remote-ratelimit RATE]
            [--upload-ratelimit RATE] [--remote-buffer UPLOAD_BUFFER]
            [--upload-buffer UPLOAD_BUFFER] [--consider-part-files]
            [--debug-profile FILE] [--rsh RSH]
            <command> ...
borg: error: unrecognized arguments: --match-archives ssh://host/./NAS
ssh://host/./NAS: Error running actions for repository
Command 'borg info --debug --show-rc --match-archives *a* ssh://host/./NAS' returned non-zero exit status 2.
/etc/borgmatic/config.yaml: Error running configuration file

As you can see, I'm using borg 1, but the newer --match-archives is being supplied.

Expected behavior (if a bug)

Normal listing.

Other notes / implementation ideas

When run in an identical PyCharm environment, the feature args get even weirder:

borg info --debug --show-rc --glob-archives {hostname}-nas-* --match-archives '*a*' ssh://host/./NAS

Environment

borgmatic version: 1.7.9 and 1.7.11

borgmatic installation method: Python venv

Borg version: 1.2.2

Python version: 3.9.2

Database version (if applicable): [version here]

operating system and version: Debian 11

#### What I'm trying to do and why Trying to run borgmatic info with the `-a` argument. #### Steps to reproduce (if a bug) Run `borgmatic -v2 -c /etc/borgmatic/config.yaml info -a '*a*'` #### Actual behavior (if a bug) ``` Ensuring legacy configuration is upgraded borg --version --debug --show-rc /etc/borgmatic/config.yaml: No commands to run for pre-actions hook ssh://host/./NAS: Displaying archive summary information borg info --debug --show-rc --match-archives *a* ssh://host/./NAS usage: borg [-V] [-h] [--critical] [--error] [--warning] [--info] [--debug] [--debug-topic TOPIC] [-p] [--iec] [--log-json] [--lock-wait SECONDS] [--bypass-lock] [--show-version] [--show-rc] [--umask M] [--remote-path PATH] [--remote-ratelimit RATE] [--upload-ratelimit RATE] [--remote-buffer UPLOAD_BUFFER] [--upload-buffer UPLOAD_BUFFER] [--consider-part-files] [--debug-profile FILE] [--rsh RSH] <command> ... borg: error: unrecognized arguments: --match-archives ssh://host/./NAS ssh://host/./NAS: Error running actions for repository Command 'borg info --debug --show-rc --match-archives *a* ssh://host/./NAS' returned non-zero exit status 2. /etc/borgmatic/config.yaml: Error running configuration file ``` As you can see, I'm using borg 1, but the newer --match-archives is being supplied. #### Expected behavior (if a bug) Normal listing. #### Other notes / implementation ideas When run in an identical PyCharm environment, the feature args get even weirder: `borg info --debug --show-rc --glob-archives {hostname}-nas-* --match-archives '*a*' ssh://host/./NAS` #### Environment **borgmatic version:** 1.7.9 and 1.7.11 **borgmatic installation method:** Python venv **Borg version:** 1.2.2 **Python version:** 3.9.2 **Database version (if applicable):** [version here] **operating system and version:** Debian 11
Owner

Thank you so much for reporting this! I've confirmed the behavior with Borg 1.2. I'm not quite sure what's going on yet, because the code is supposed to check the local Borg version and use --match-archives or --glob-archives as appropriate. I'll dig into this and let you know what I find.

Thank you so much for reporting this! I've confirmed the behavior with Borg 1.2. I'm not quite sure what's going on yet, because the code is *supposed* to check the local Borg version and use `--match-archives` or `--glob-archives` as appropriate. I'll dig into this and let you know what I find.
witten added the
bug
label 2023-04-04 03:22:22 +00:00
Author

Yep, agreed... I did see the cool stuff being done in borg/feature.py etc, and even ran tests via tox -- even made another test as below and it strangely passed!

def test_version_checker():
    assert not module.available(module.Feature.MATCH_ARCHIVES, '1.2.2')
Yep, agreed... I did see the cool stuff being done in `borg/feature.py` etc, and even ran tests via `tox` -- even made another test as below and it strangely passed! ``` def test_version_checker(): assert not module.available(module.Feature.MATCH_ARCHIVES, '1.2.2') ```
Collaborator

I Was able to debug this:

The problem is with this line in info.py::display_archives_info() (line55):

flags.make_flags_from_arguments(
            info_arguments, excludes=('repository', 'archive', 'prefix')
        )

When I added match_prefix to the excludes argument for make_flags_from_arguments, the error did not occur anymore.

I Was able to debug this: The problem is with this line in `info.py::display_archives_info()` (line55): ```python flags.make_flags_from_arguments( info_arguments, excludes=('repository', 'archive', 'prefix') ) ``` When I added `match_prefix` to the `excludes` argument for `make_flags_from_arguments`, the error did not occur anymore.
Owner

Aha! Nice catch. I'll make that fix and see if there's a way to catch this sort of issue in an integration test.

Aha! Nice catch. I'll make that fix and see if there's a way to catch this sort of issue in an integration test.
Author

I Was able to debug this:

The problem is with this line in info.py::display_archives_info() (line55):

flags.make_flags_from_arguments(
            info_arguments, excludes=('repository', 'archive', 'prefix')
        )

When I added match_prefix to the excludes argument for make_flags_from_arguments, the error did not occur anymore.

Not being fully immersed in the code, would this fix not need to be in other lines too, wherever --archive is accepted?

> I Was able to debug this: > > The problem is with this line in `info.py::display_archives_info()` (line55): > > ```python > flags.make_flags_from_arguments( > info_arguments, excludes=('repository', 'archive', 'prefix') > ) > ``` > > When I added `match_prefix` to the `excludes` argument for `make_flags_from_arguments`, the error did not occur anymore. Not being fully immersed in the code, would this fix not need to be in other lines too, wherever `--archive` is accepted?
Owner

Yes, this is likely a bug in multiple different actions. And what's worse, it looks like even once fixed, the -a/--match-archives/--glob-archives flag on the command-line isn't correctly overriding any of the other places that value can come from. Fortunately the fix should be pretty straightforward.

Yes, this is likely a bug in multiple different actions. And what's worse, it looks like even once fixed, the `-a`/`--match-archives`/`--glob-archives` flag on the command-line isn't correctly overriding any of the [other places](https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#archive-naming) that value can come from. Fortunately the fix should be pretty straightforward.
Owner

This has been fixed in master for all relevant actions. I also fixed the related --match-archives override problem mentioned above. Lastly, I added a few integration tests that lightly "fuzz" some of the the functions that produce Borg arguments to hopefully catch related issues in the future.

These fixes will be part of the next release. Thanks again for taking the time to file this. And thanks to @diivi for diagnosing!

This has been fixed in master for all relevant actions. I also fixed the related `--match-archives` override problem mentioned above. Lastly, I added a few integration tests that lightly "fuzz" some of the the functions that produce Borg arguments to hopefully catch related issues in the future. These fixes will be part of the next release. Thanks again for taking the time to file this. And thanks to @diivi for diagnosing!
Author

You're awesome Dan, always a pleasure dealing with you :)

You're awesome Dan, always a pleasure dealing with you :)
Owner

This fix has been released as part of borgmatic 1.7.12!

This fix has been released as part of borgmatic 1.7.12!
Sign in to join this conversation.
No Milestone
No Assignees
3 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#666
No description provided.