Replace create --hostname/--username with BORG_HOSTNAME/BORG_USERNAME env vars, fixes #9651#9811
Open
ThomasWaldmann wants to merge 1 commit into
Open
Conversation
… env vars, fixes borgbackup#9651 The --hostname/--username options on borg create (added in 2.0.0b21, borgbackup#9402) are removed in favor of the BORG_HOSTNAME / BORG_USERNAME environment variables. When set, these override the hostname/username stored in newly created archives and used by the {hostname}/{user} placeholders (so they also apply to archive names, prune --glob-archives, check, etc.). Useful to run borg on host A but impersonate host B. The env vars are read at the point of use; fqdn/hostid (see BORG_HOST_ID) and the auto-detection are intentionally left untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35f6080 to
5e27122
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9811 +/- ##
=======================================
Coverage 84.77% 84.77%
=======================================
Files 92 92
Lines 15289 15285 -4
Branches 2297 2297
=======================================
- Hits 12961 12958 -3
+ Misses 1630 1629 -1
Partials 698 698 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forward-port of the 1.4-maint env-var approach (#9810) to master, and removal of the
borg create --hostname/--usernameCLI options (added in 2.0.0b21, #9402).Per maintainer decision, hostname/username overriding is now env-vars only:
BORG_HOSTNAME— overrides the hostnameBORG_USERNAME— overrides the usernameWhen set, the override is used both for the value stored in newly created
archives and for the
{hostname}/{user}placeholders (so it alsoapplies to archive names,
prune --glob-archives '{hostname}-*',check, etc.).Use case (#9651): run borg on host A but impersonate host B — e.g. a reliably
online machine performs prune/compact/check on behalf of an opportunistically
online laptop against a shared, deduplicated repository, with consistent
per-hostname archive naming.
Fixes #9651.
Changes
--hostname/--usernameoptions and the correspondingArchive.__init__parameters.Archive.save()now storesos.environ.get("BORG_HOSTNAME") or platform.hostnameand
os.environ.get("BORG_USERNAME") or getuser()._replace_placeholders()honors the same overrides for{hostname}/{user}.fqdn,hostid(lock stale-removal, seeBORG_HOST_ID) and the normalauto-detection are intentionally left untouched.
createusage; changelog entryunder 2.0.0b22.
test_hostname_and_username_override, now driving the featurevia env vars and also asserting
{hostname}-{user}placeholder substitution inthe archive name.
Note
This is a breaking change relative to the 2.0.0b21 beta for anyone who used
--hostname/--username, but beta releases are explicitly test-only, so this isacceptable.
🤖 Generated with Claude Code