Read BORG_RELOCATED_REPO_ACCESS_IS_OK environment variable #707

Closed
opened 2023-05-30 18:05:08 +00:00 by hrv231 · 4 comments

What I'm trying to do and why

Running borg check or borg check --repair to a repository that has been moved location recently.

Steps to reproduce (if a bug)

docker run
-d
--name='borgmatic'
--net='bridge'
-e TZ="America/Los_Angeles"
-e HOST_CONTAINERNAME="borgmatic"
-e 'TZ'='America/Los_Angeles'
-e 'BORG_RELOCATED_REPO_ACCESS_IS_OK'='yes'

Actual behavior (if a bug)

/mnt/borg-repository/borg_backup/repo1: Listing archives
Warning: The repository at location /mnt/borg-repository/borg_backup/repo1 was previously located at /mnt/borg-repository/repo1
Do you want to continue? [yN] no (from BORG_RELOCATED_REPO_ACCESS_IS_OK)
Aborting.
Repository access aborted

Expected behavior (if a bug)

/ # borg list /mnt/borg-repository/borg_backup/repo1
Enter passphrase for key /mnt/borg-repository/borg_backup/repo1:
Warning: The repository at location /mnt/borg-repository/borg_backup/repo1 was previously located at /mnt/borg-repository/repo1
Do you want to continue? [yN] yes (from BORG_RELOCATED_REPO_ACCESS_IS_OK)
repo1-2022-11-30T18:15:00 Wed, 2022-11-30 18:15:27
repo1-2022-12-31T18:15:00 Sat, 2022-12-31 18:15:14
repo1-2023-01-31T18:15:01 Tue, 2023-01-31 18:15:15

Other notes / implementation ideas

When running borgmatic check, borgmatic is not able to read the BORG_RELOCATED_REPO_ACCESS_IS_OK environment and automatically type "no" for me, however borg does read and execute it properly.

I think there has to be a way for borgmatic to read that environment the same way as borg is able to do so.

I tested this with borgmatic 1.7.9 and 1.7.13; borg 1.2.3 and 1.2.4 both are able to detect 'BORG_RELOCATED_REPO_ACCESS_IS_OK'='yes' properly.

To know more about it: https://github.com/borgbackup/borg/issues/1426#issuecomment-236919222

Environment

borgmatic version: [1.7.13]

borgmatic installation method: [Docker container]

Borg version: [1.2.4]

Python version: [3.11.2]

#### What I'm trying to do and why Running *borg check* or *borg check --repair* to a repository that has been moved location recently. #### Steps to reproduce (if a bug) docker run -d --name='borgmatic' --net='bridge' -e TZ="America/Los_Angeles" -e HOST_CONTAINERNAME="borgmatic" -e 'TZ'='America/Los_Angeles' -e 'BORG_RELOCATED_REPO_ACCESS_IS_OK'='yes' #### Actual behavior (if a bug) /mnt/borg-repository/borg_backup/repo1: Listing archives Warning: The repository at location /mnt/borg-repository/borg_backup/repo1 was previously located at /mnt/borg-repository/repo1 Do you want to continue? [yN] **no** (from BORG_RELOCATED_REPO_ACCESS_IS_OK) Aborting. Repository access aborted #### Expected behavior (if a bug) / # borg list /mnt/borg-repository/borg_backup/repo1 Enter passphrase for key /mnt/borg-repository/borg_backup/repo1: Warning: The repository at location /mnt/borg-repository/borg_backup/repo1 was previously located at /mnt/borg-repository/repo1 Do you want to continue? [yN] **yes** (from BORG_RELOCATED_REPO_ACCESS_IS_OK) repo1-2022-11-30T18:15:00 Wed, 2022-11-30 18:15:27 repo1-2022-12-31T18:15:00 Sat, 2022-12-31 18:15:14 repo1-2023-01-31T18:15:01 Tue, 2023-01-31 18:15:15 #### Other notes / implementation ideas When running *borgmatic check*, borgmatic is not able to read the BORG_RELOCATED_REPO_ACCESS_IS_OK environment and automatically type "no" for me, however *borg* does read and execute it properly. I think there has to be a way for borgmatic to read that environment the same way as borg is able to do so. I tested this with borgmatic 1.7.9 and 1.7.13; borg 1.2.3 and 1.2.4 both are able to detect 'BORG_RELOCATED_REPO_ACCESS_IS_OK'='yes' properly. To know more about it: https://github.com/borgbackup/borg/issues/1426#issuecomment-236919222 #### Environment **borgmatic version:** [1.7.13] **borgmatic installation method:** [Docker container] **Borg version:** [1.2.4] **Python version:** [3.11.2]
Contributor

I've not used the docker image, but for what it's worth there's an option for this in the borgmatic configuration file

    # Bypass Borg error about a repository that has been moved.
    # Defaults to false.
    # relocated_repo_access_is_ok: true

You can probably override the configuration in the command line invocation instead for a one-off: https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#configuration-overrides

I've not used the docker image, but for what it's worth there's an option for this in the borgmatic [configuration file](https://torsion.org/borgmatic/docs/reference/configuration/) ``` # Bypass Borg error about a repository that has been moved. # Defaults to false. # relocated_repo_access_is_ok: true ``` You can probably override the configuration in the command line invocation instead for a one-off: https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#configuration-overrides
Owner

Thanks for filing this! Seems like a reasonable feature request. But yeah, you can use the existing configuration option in the meantime as @s1shed points out.

Thanks for filing this! Seems like a reasonable feature request. But yeah, you can use the existing configuration option in the meantime as @s1shed points out.
witten changed title from borgmatic is not able to read some of borg options to Read BORG_RELOCATED_REPO_ACCESS_IS_OK environment variable 2023-05-30 19:00:21 +00:00
Owner

For anyone looking to implement this: I'd recommend keeping the existing configuration option, but then if the BORG_RELOCATED_REPO_ACCESS_IS_OK environment variable is set, use that to override that config option. There's also the separate BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK environment variable / unknown_unencrypted_repo_access_is_ok config option, which would be nice to roll into this work.

The changes in question would likely go into borgmatic/borg/environment.py:make_environment().

For anyone looking to implement this: I'd recommend keeping the existing configuration option, but then if the `BORG_RELOCATED_REPO_ACCESS_IS_OK` environment variable is set, use that to override that config option. There's also the separate `BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK` environment variable / `unknown_unencrypted_repo_access_is_ok` config option, which would be nice to roll into this work. The changes in question would likely go into `borgmatic/borg/environment.py:make_environment()`.
witten added the
design finalized
good first issue
labels 2023-05-30 20:01:06 +00:00
Owner

So I just checked this with the most recent borgmatic release, and setting the BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK environment variable does cause borgmatic to pass that variable through to Borg as long as the relocated_repo_access_is_ok option isn't set in borgmatic's configuration file. If the relocated_repo_access_is_ok option is set, then that overrides the environment variable. That actually seems like the right precedence to me, so I'm going to call this "done" for now. But if you have other feedback and/or have issues getting this working, please do let me know.

So I just checked this with the most recent borgmatic release, and setting the BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK environment variable _does_ cause borgmatic to pass that variable through to Borg as long as the `relocated_repo_access_is_ok` option isn't set in borgmatic's configuration file. If the `relocated_repo_access_is_ok` option is set, then that overrides the environment variable. That actually seems like the right precedence to me, so I'm going to call this "done" for now. But if you have other feedback and/or have issues getting this working, please do let me know.
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#707
No description provided.