Prune action with prefix sends duplicate --glob-archives flags to Borg #668

Closed
opened 2023-04-05 20:53:43 +00:00 by witten · 3 comments
Owner

What I'm trying to do and why

Run prune during a dry run to reproduce an issue discovered by a Redditor.

Steps to reproduce

Using this configuration in test.yaml:

location:
    source_directories:
        - test

    repositories:
        - test.borg

storage:
    archive_name_format: 'test-{now}'

retention:
    keep_daily: 7
    prefix: 'test-'

Run the following:

borgmatic -c test.yaml -v 2 --dry-run prune

This also repros without the --dry-run flag.

Actual behavior

...
summary:
test.yaml: An error occurred
test.borg: Error running actions for repository
usage: borg prune [-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] [-n] [--force] [-s]
                  [--list] [--keep-within INTERVAL] [--keep-last SECONDLY]
                  [--keep-minutely MINUTELY] [-H HOURLY] [-d DAILY]
                  [-w WEEKLY] [-m MONTHLY] [-y YEARLY] [-P PREFIX | -a GLOB]
                  [--save-space] [-c SECONDS]
                  [REPOSITORY]
borg prune: error: argument -a/--glob-archives: There can be only one.
Command 'borg prune --keep-daily 7 --glob-archives test-* --glob-archives test-* --debug --show-rc --dry-run test.borg' returned non-zero exit status 2.

Need some help? https://torsion.org/borgmatic/#issues

Expected behavior

bormgatic only sending --glob-archives once to Borg, no error from Borg.

Other notes / implementation ideas

You'd think that the fixes and integration tests for duplicate flags in #666 would handle this case! You'd be wrong.

Environment

borgmatic version: master (after 1.7.11)

borgmatic installation method: pip install --editable

Borg version: 1.2.4

Python version: 3.10.10

operating system and version: Manjaro Linux stable

#### What I'm trying to do and why Run `prune` during a dry run to reproduce [an issue discovered by a Redditor](https://www.reddit.com/r/BorgBackup/comments/12ctoqi/getting_error_two_globarchives_with_borgmatic/). #### Steps to reproduce Using this configuration in `test.yaml`: ```yaml location: source_directories: - test repositories: - test.borg storage: archive_name_format: 'test-{now}' retention: keep_daily: 7 prefix: 'test-' ``` Run the following: ```bash borgmatic -c test.yaml -v 2 --dry-run prune ``` This also repros without the `--dry-run` flag. #### Actual behavior ```bash ... summary: test.yaml: An error occurred test.borg: Error running actions for repository usage: borg prune [-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] [-n] [--force] [-s] [--list] [--keep-within INTERVAL] [--keep-last SECONDLY] [--keep-minutely MINUTELY] [-H HOURLY] [-d DAILY] [-w WEEKLY] [-m MONTHLY] [-y YEARLY] [-P PREFIX | -a GLOB] [--save-space] [-c SECONDS] [REPOSITORY] borg prune: error: argument -a/--glob-archives: There can be only one. Command 'borg prune --keep-daily 7 --glob-archives test-* --glob-archives test-* --debug --show-rc --dry-run test.borg' returned non-zero exit status 2. Need some help? https://torsion.org/borgmatic/#issues ``` #### Expected behavior bormgatic only sending `--glob-archives` once to Borg, no error from Borg. #### Other notes / implementation ideas You'd think that the fixes and integration tests for duplicate flags in #666 would handle this case! You'd be wrong. #### Environment **borgmatic version:** master (after 1.7.11) **borgmatic installation method:** `pip install --editable` **Borg version:** 1.2.4 **Python version:** 3.10.10 **operating system and version:** Manjaro Linux stable
witten added the
bug
label 2023-04-05 20:53:43 +00:00
Author
Owner

Looking at the code (make_prune_flags()), it's pretty clear why this happening—the code is not even making an effort to toggle between prefix making --match-archives and archive_name_format making --match-archives. It just blindly does both if prefix is set. Ugh, who was the joker who let this slip through? 😆

Looking at the code (`make_prune_flags()`), it's pretty clear why this happening—the code is not even making an effort to toggle between `prefix` making `--match-archives` and `archive_name_format` making `--match-archives`. It just blindly does both if `prefix` is set. Ugh, who was the joker who let this slip through? 😆
Author
Owner

Fixed in master. Will be part of the next release.

Fixed in master. Will be part of the next release.
Author
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
1 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#668
No description provided.