Skip to content

fix: put the Borg subcommand at cmd[1] for compact, mount and change-passphrase - #2631

Merged
m3nu merged 1 commit into
masterfrom
fix/2607-borg-subcommand-position
Nov 15, 2026
Merged

m3nu merged 1 commit into
masterfrom
fix/2607-borg-subcommand-position

Conversation

@m3nu

@m3nu m3nu commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Description

BorgJob treats cmd[1] as the Borg subcommand: it is stored as EventLogModel.subcommand, used in the sleep-inhibitor reason and passed to the scheduler's post-backup handling. Three jobs put global options first, so they logged an option instead:

Job Before Now
compact borg --info --log-json compact --progress … borg compact --info --log-json --progress …
change passphrase borg --info --log-json key change-passphrase … borg key change-passphrase --info --log-json …
mount borg --log-json mount … borg mount --log-json …

The scheduler looked for a recent compaction with subcommand == '--info'. A passphrase change logged the same value, so changing the passphrase postponed scheduled compaction by compaction_weeks.

Changes:

  • The three jobs put the subcommand first, like every other job.
  • The compaction query in scheduler/execution.py matches compact, and still matches --info so that compactions logged before this change count. Without that, the first post-backup run after upgrading would compact again. The legacy value can go once those rows have been pruned (event log rows are kept for about six months).

Side effects:

  • New event log rows show compact, key and mount. Existing rows are not migrated: old compaction and passphrase-change rows cannot be told apart.
  • A passphrase change made before upgrading still counts as a compaction until its row ages out of the window.
  • Extra Borg arguments from the repo settings are inserted after cmd[1], so for these jobs they move from before the subcommand to after it. For change passphrase they sit between key and change-passphrase.

Related Issue

Fixes #2607

Motivation and Context

See above. The unused cmd log-context key and a per-job subcommand attribute, both mentioned in the issue, are left alone.

How Has This Been Tested?

On macOS with Borg 1.4.3 (nox default).

  • tests/unit/test_borg_argv.py: the full-argv expectations for compact, change passphrase and mount are updated for Borg 1 and Borg 2, plus one new-order case for the Borg 1 mount-point parser.
  • tests/unit/test_scheduler.py: compaction cases for compact (recent, failed, too old), a legacy --info row, and a key row that must not count.
  • tests/unit/test_archives.py::test_repo_compact now asserts the event log row written by the job has subcommand == 'compact'. It also sets the Borg version with monkeypatch instead of assigning the global and resetting it to 1.1.0.
  • With the source changes reverted, 14 of these tests fail; with them, the three files give 308 passed.
  • Full unit suite: 687 passed, 8 skipped, 1 deselected (test_keyring_darwin.py::test_keyring_non_ascii_repo, which writes to the real login keychain).
  • Against real Borg 1.4.3 on a scratch repo: compact and change passphrase ran in the new order, also with --lock-wait 5 inserted where the extra arguments go. Mount got past argument parsing and stopped at "no FUSE support".

Not tested:

  • No Borg 2 binary was run. That Borg 2 accepts the new order rests on reading its parser source (common options are accepted on the compact, mount and key change-passphrase parsers, and on key) and on every other Vorta job already passing these options after the subcommand.
  • Integration tests and a real FUSE mount were not run locally.

Known limitation, Borg 2 only: extra Borg arguments now come after mount, so the Borg 2 mount-point parser (extract_mount_points_v2) sees them. The common value options are already in its skip list. A value option that is not, such as --socket, would be mistaken for the mount point.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

…passphrase

BorgJob logs cmd[1] as the subcommand. Compact, change-passphrase and
mount put global options first, so they were logged as '--info' or
'--log-json'. The scheduler found recent compactions by matching
'--info', which a passphrase change also matched, so changing the
passphrase postponed scheduled compaction.

Move the options after the subcommand and match 'compact' in the
scheduler. Keep matching the legacy '--info' rows so the first
post-backup run after upgrading does not trigger an extra compact;
the legacy value can be removed once those rows have been pruned.

Fixes #2607
@m3nu
m3nu merged commit 5a945f3 into master Nov 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Put Borg subcommand at cmd[1] for compact, mount and change-passphrase

1 participant