summaryrefslogtreecommitdiff
path: root/hosts/vidhar/postgresql.nix
blob: fa5b734f33832e9aee53ef4cdca24e45ac0e41f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ pkgs, config, flake, flakeInputs, ... }:

let
  nixpkgs-pgbackrest = import (flakeInputs.nixpkgs-pgbackrest.outPath + "/pkgs/top-level") {
    overlays = [ flake.overlays.libdscp ];
    localSystem = config.nixpkgs.system;
  };
in {
  config = {
    services.postgresql = {
      enable = true;
      package = pkgs.postgresql_15;
    };

    services.pgbackrest = {
      settings."vidhar" = {
        pg1-path = config.services.postgresql.dataDir;

        repo1-path = "/var/lib/pgbackrest";
        repo1-retention-full-type = "time";
        repo1-retention-full = 14;
        repo1-retention-archive = 7;
      };

      backups."vidhar-daily" = {
        stanza = "vidhar";
        repo = "1";
        timerConfig.OnCalendar = "daily";
      };
    };
  };
}