borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11.23k stars 743 forks source link

Borg mount does not read BORG_REPO env variable #8255

Closed felixschndr closed 4 months ago

felixschndr commented 4 months ago

Have you checked borgbackup docs, FAQ, and open GitHub issues?

Yes

Is this a BUG / ISSUE report or a QUESTION?

bug / issue

System information. For client/server mode post info for both machines.

Your borg version (borg -V).

borg 1.2.0

Since Ubuntu apt only has this old version available I am not sure that this is not fixed with a new version however I did not find anything in the changelog in a glance.

Operating system (distribution) and version.

Ubuntu 22.04

Describe the problem you're observing.

Borg mount does not use the BORG_REPO env variable.

In my shell I exported BORG_REPO and BORG_PASSPHRASE. When running borg list I don't have to supply the repo or password (as expected). When running borg mount I get the following error:

┌─[23:37:11]-[:(]-[root💀grievous]-[/home/felix/bashrc/grievous/private/ (master)]
└──> borg mount /mnt/test
usage: borg mount [-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] [--consider-checkpoints] [-f] [-o OPTIONS] [--numeric-owner] [--numeric-ids] [-P PREFIX | -a GLOB] [--sort-by KEYS]
                  [--first N | --last N] [-e PATTERN] [--exclude-from EXCLUDEFILE] [--pattern PATTERN] [--patterns-from PATTERNFILE] [--strip-components NUMBER]
                  REPOSITORY_OR_ARCHIVE MOUNTPOINT [PATH ...]
borg mount: error: the following arguments are required: MOUNTPOINT, PATH

Running borg mount $BORG_REPO /mnt/test works. So it uses the BORG_PASSPHRASE automatically, just not the BORG_REPO.

I'd expect borg mount /mnt/test to run (the same as borg list) without asking for a password (which it does not, so no change needed there) and without asking for a repo (which is does, change needed there)

ThomasWaldmann commented 4 months ago

Well, I am pretty sure it does read BORG_REPO.

But, what we have here is like an argument parsing issue with the positional arguments:

It expects at least REPOSITORY_OR_ARCHIVE and MOUNTPOINT, plus optionally PATH.

So, try that:

borg mount :: /mnt/test         # mount whole repo (using BORG_REPO env var)
borg mount ::ARCHIVE /mnt/test  # mount one archive (using BORG_REPO env var)
ThomasWaldmann commented 4 months ago

https://borgbackup.readthedocs.io/en/stable/usage/mount.html - guess we should have these examples there also.

ThomasWaldmann commented 4 months ago

Note: this issue (and the doc updates) do not apply to master branch (borg2):

In borg2, the repo is given either by a -r REPO option or read from BORG_REPO env var. Because it is an option and not a positional argument, giving it or leaving it away does not shift positions of the positional arguments.

ThomasWaldmann commented 4 months ago

Fixed in 1.2-maint and 1.4-maint. No fix needed for master.

felixschndr commented 4 months ago

Thank you :)