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.
Postgresql backup
Hi, thought I'd have a go at enabling backups for postgresql, as it stores a lot of important data, for example for Nextcloud.
I'm not sure what the best way to do it is, so below are some of my thoughts.
One-shot backup vs per-service backup
I suppose there are many ways to set up the backup, but the simplest seems to be
pg_dumpall
which dumps all tables, schema, users etc. into an SQL file which can be piped back topsql
to reproduce the DB. This is nice because it is simple, and because users etc. are preserved. It's also pretty nice for services that don't really have any state but their database -- they get backups for free.Another way to do it would be to have each service back up its own database, i.e. nextcloud uses
pg_dump
to back up only thenextcloud
database. The main advantage here, I suppose, is that the database dumped for nextcloud is (probably) in sync with the nextcloud backup. The main drawback is that it's a lot more code to set up, as it'd have to be done for all relevant services, and I'm guessing that restoring from backup might be a bit more challenging. At the very least, we'd have to restore from many backed up sql files.Existing nixpkgs service
There is an existing service for backup from postgresql, but I thought it was better to use our own script. Both because it is very simple, and because it's easier to align the
pg_dump
with restic backups using the backup contract hooks.Implementation and testing
I haven't tested out the implementation yet, and I'm not sure whether just putting the backup script in the default for the backup option is the right way to go?