| 1 | { config, pkgs, ... }: |
| 2 | |
| 3 | { |
| 4 | fileSystems."/var/lib/postgresql" = { |
| 5 | device = "zroot/root/postgresql"; |
| 6 | fsType = "zfs"; |
| 7 | options = [ "zfsutil" ]; |
| 8 | }; |
| 9 | |
| 10 | services.postgresql = { |
| 11 | enable = true; |
| 12 | enableJIT = true; |
| 13 | package = pkgs.postgresql_16_jit; |
| 14 | }; |
| 15 | |
| 16 | # create database dumps |
| 17 | services.postgresqlBackup = { |
| 18 | enable = true; |
| 19 | compression = "zstd"; |
| 20 | # pulled in through the backup job |
| 21 | startAt = [ ]; |
| 22 | }; |
| 23 | |
| 24 | # include postgres dumps in the backup |
| 25 | services.backup = { |
| 26 | includes = [ "/var/backup/postgresql" ]; |
| 27 | wantedUnits = |
| 28 | if config.services.postgresqlBackup.databases == [ ] then |
| 29 | [ "postgresqlBackup.service" ] |
| 30 | else |
| 31 | map (db: "postgresqlBackup-${db}.service") config.services.postgresqlBackup.databases; |
| 32 | }; |
| 33 | } |