Optionally pass through PostgreSQL environment variables in database hook #370
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#370
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported by
hugokernel
on IRC.What I'm trying to do and why
Backup a database with borgmatic via the PostgreSQL database hook, passing through some of the credentials or connection information via
PG*
environment variables so that I don't have to specify them in borgmatic's configuration file.Perhaps I'm using Docker and environment variables are more convenient for this purpose. Perhaps I already have them in the environment for some other usage. Perhaps I have several databases with the same settings or credentials, and I don't want to have to repeat the configuration for each one in borgmatic's database hook.
Other notes / implementation ideas
Any existing
PG*
environment variables are not passed through from borgmatic to PostgreSQL today becausePGSSLMODE
is set unconditionally in the new environment that borgmatic passes to PostgreSQL: https://projects.torsion.org/witten/borgmatic/src/branch/master/borgmatic/hooks/postgresql.py#L25Adding a conditional around that line would make the environment empty, which would pass
env=None
to the PostgreSQL call, which would in effect default to borgmatic's own environment.Some relevant discussion with a related proposal on #546.
There's a new feature implemented as part of #546 for environment variable interpolation, very related to this ticket although not exactly the same. See the documentation at https://torsion.org/borgmatic/docs/how-to/provide-your-passwords/
Well this took an embarrassingly long time to implement. Fixed in main.
Released in borgmatic 1.8.8!