Run arbitrary Borg commands #425

Closed
opened 2021-06-14 22:59:35 +00:00 by witten · 3 comments
Owner

What I'm trying to do and why

An oft-mentioned feature request is the ability for borgmatic to run Borg commands with arbitrary arguments.

The "why" is that borgmatic actions do not currently wrap all current or future Borg commands/options. (See #394 for an example.) So sometimes it would be nice to drop down to running Borg (nearly) directly while still making use of all the niceties of borgmatic's configuration with repositories, SSH settings, etc.

Proposed design

There could be a new "borg" action something like this:

borgmatic -c config.yaml -v 2 borg break-lock

Which would run a borg command like:

borg break-lock --debug --show-rc test.borg

Whereas this:

borgmatic -v 2 -c test.yaml borg --archive test list

Would run a borg command like:

borg list --debug --show-rc test.borg::test

Unlike all other borgmatic actions that can share options, this action would work by "greedily" consuming any Borg arguments following "borg" and not share them with other borgmatic actions. Global borgmatic options could still go before the "borg" action.

When running the given Borg command, repository name (and archive name, where applicable) would be constructed entirely by borgmatic to take advantage of its repositories listed in configuration. This means that repository/archive names should not be specified as part of the supplied Borg options.

Help for the new action might look something like this:

usage: borgmatic borg [--repository REPOSITORY] [--archive ARCHIVE] [OPTION [OPTION ...]] [-h]

Run an arbitrary Borg command based on borgmatic's configuration

borg arguments:
  --repository REPOSITORY
                        Path of repository to pass to Borg, defaults to the configured repositories
  --archive ARCHIVE     Name of archive to pass to Borg (or "latest")
  OPTION [OPTION ...]   Options to pass to Borg
  -h, --help            Show this help message and exit
#### What I'm trying to do and why An oft-mentioned feature request is the ability for borgmatic to run Borg commands with arbitrary arguments. The "why" is that borgmatic actions do not currently wrap all current or future Borg commands/options. (See #394 for an example.) So sometimes it would be nice to drop down to running Borg (nearly) directly while still making use of all the niceties of borgmatic's configuration with repositories, SSH settings, etc. #### Proposed design There could be a new "borg" action something like this: ```bash borgmatic -c config.yaml -v 2 borg break-lock ``` Which would run a borg command like: ```bash borg break-lock --debug --show-rc test.borg ``` Whereas this: ```bash borgmatic -v 2 -c test.yaml borg --archive test list ``` Would run a borg command like: ```bash borg list --debug --show-rc test.borg::test ``` Unlike all other borgmatic actions that can share options, this action would work by "greedily" consuming any Borg arguments following "borg" and not share them with other borgmatic actions. Global borgmatic options could still go before the "borg" action. When running the given Borg command, repository name (and archive name, where applicable) would be constructed entirely by borgmatic to take advantage of its `repositories` listed in configuration. This means that repository/archive names should not be specified as part of the supplied Borg options. Help for the new action might look something like this: ``` usage: borgmatic borg [--repository REPOSITORY] [--archive ARCHIVE] [OPTION [OPTION ...]] [-h] Run an arbitrary Borg command based on borgmatic's configuration borg arguments: --repository REPOSITORY Path of repository to pass to Borg, defaults to the configured repositories --archive ARCHIVE Name of archive to pass to Borg (or "latest") OPTION [OPTION ...] Options to pass to Borg -h, --help Show this help message and exit ```
witten added the
design finalized
label 2021-06-14 23:01:20 +00:00
Author
Owner
Released in borgmatic 1.5.15! Docs here: https://torsion.org/borgmatic/docs/how-to/run-arbitrary-borg-commands/

thank you very very much, thos will save me a lot of time. ☺

thank you very very much, thos will save me a lot of time. ☺
Author
Owner

I'm so glad to hear it! Since there are several limitations with the new action (see the docs), please let me know if any of them prove problematic for your use cases. I wanted to optimize for speed rather than "perfect".

I'm so glad to hear it! Since there are several limitations with the new action (see the docs), please let me know if any of them prove problematic for your use cases. I wanted to optimize for speed rather than "perfect".
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#425
No description provided.