Database restore hooks for PostgreSQL #229
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#229
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
What I'm trying to do and why
For a real killer feature, the database hook feature begun in #225 could also trigger during
borgmatic extract
. Specifically, it could restore your databases from dumps.. and not just extract your plain files! So if you're restoring on a completely fresh system, you could get up and running relatively quickly—including your databases—without no manual work.Other notes / implementation ideas
For safety reasons, database restores should probably not be completely automatic when running
borgmatic extract
, because then it'd be easy to accidentally destroy or replace a production database. Instead, you should have to provide an explicit command-line flag toborgmatic extract
that explicitly requests a database to restore (or "all"). Or maybe there should be a completely separate sub-command:borgmatic restore-postgresql
.Another consideration: When restoring, it may be necessary to include explicit support for restoring to a host other than the one that a database dump originally came from. That's because the original database host may be toast, and the user is trying to spin up a new replacement host with a different hostname. In that case, a
--rewrite-hostname
flag may be necessary.Another: Should there be a way to pass arbitrary arguments through from
borgmatic restore
topg_restore
?Yet another thought: If, during restores, borgmatic relies on databases being defined in the borgmatic configuration file, then that poses a bit of a problem: The user may not have backed up
/etc/borgmatic/config.yaml
, and yet may still want to restore their databases. Two different ideas on how to deal with this:Implement a general-purpose feature for borgmatic to backup its own configuration file(s), e.g. to
~/.borgmatic/config.yaml
/~/.borgmatic/borgmatic.d/
. (This would be part of a separate ticket.) Note that there are security implications to think through here, since config file can contain credentials. Then, when restoring a database, optionally first restore a config file so that the databases are known and configured.Alternatively, when writing a database dump into
~/.borgmatic/postgresql_databases/...
, also write out metadata about the database into a separate file (hostname, username, password(?), etc.) alongside the dump. That way, during restore, if borgmatic's config file isn't configured for any databases, you still have the connection metadata necessary to restore a given database!Decided to just document around this for now: Encouraging users to backup their borgmatic configuration files.
Released in 1.4.1.