aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name/po/postgresql
diff options
context:
space:
mode:
authorSoispha Peetz <soispha@b-peetz.de>2026-10-31 16:20:35 +0100
committerSoispha Peetz <soispha@b-peetz.de>2026-11-27 00:28:58 +0100
commitddb7c4fd9da0b877db276f473d78785b7dfa2cae (patch)
treed6c0a70b54c71ab5be720d1427f27ed24b80fdc6 /modules/by-name/po/postgresql
parentunflake.nix: Update (diff)
downloadnixos-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 'modules/by-name/po/postgresql')
-rw-r--r--modules/by-name/po/postgresql/module.nix20
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;
};
}