From ddb7c4fd9da0b877db276f473d78785b7dfa2cae Mon Sep 17 00:00:00 2001 From: Soispha Peetz Date: Sat, 31 Oct 2026 16:20:35 +0100 Subject: modules/{postgresql,backup}: Massively improve the backup module E.g. we now actually ignore the `/var/lib/postgresql` path. --- modules/by-name/po/postgresql/module.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'modules/by-name/po') 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; }; } -- cgit v1.3.1