diff options
| author | Soispha Peetz <soispha@b-peetz.de> | 2026-10-31 16:20:35 +0100 |
|---|---|---|
| committer | Soispha Peetz <soispha@b-peetz.de> | 2026-11-27 00:28:58 +0100 |
| commit | ddb7c4fd9da0b877db276f473d78785b7dfa2cae (patch) | |
| tree | d6c0a70b54c71ab5be720d1427f27ed24b80fdc6 /modules/by-name/po | |
| parent | unflake.nix: Update (diff) | |
| download | nixos-server-ddb7c4fd9da0b877db276f473d78785b7dfa2cae.zip | |
modules/{postgresql,backup}: Massively improve the backup module
E.g. we now actually ignore the `/var/lib/postgresql` path.
Diffstat (limited to '')
| -rw-r--r-- | modules/by-name/po/postgresql/module.nix | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/by-name/po/postgresql/module.nix b/modules/by-name/po/postgresql/module.nix index 319c3ac..ccc08b3 100644 --- a/modules/by-name/po/postgresql/module.nix +++ b/modules/by-name/po/postgresql/module.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: let cfg = config.vhack.postgresql; @@ -14,6 +15,25 @@ in { "/var/lib/postgresql" ]; + vhack.services.backup = { + exclude = [ + "/var/lib/postgresql" # included in the db dump + ]; + + backupPrepare.postgresql = '' + ${lib.getExe pkgs.sudo} -u postgres \ + ${lib.getExe' "pg_dumpall" pkgs.postgresql} \ + --clean \ + --if-exists \ + --quote-all-identifiers | + ${lib.getExe pkgs.xz} \ + --compress \ + -9 \ + --extreme \ + --threads=0 > /srv/db_backup.sql.xz + ''; + }; + services.postgresql.enable = true; }; } |
