machines: serv: add automated backups for postgresql dumps

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2023-12-02 19:57:27 +01:00
parent d6f2ba592e
commit 2553081390
Signed by: c8h4
GPG key ID: 6817E9C75C0785D7
7 changed files with 24 additions and 1 deletions

View file

@ -6,6 +6,8 @@
../modules/services/filebrowser.nix
../modules/services/homer.nix
../secrets/morph/acme.nix
../secrets/morph/restic.nix
../secrets/morph/serv.nix
../secrets/morph/sourcehut
../services/nginx.nix
../services/paperless.nix
@ -36,5 +38,12 @@
inherit (my.homelab.services.homer) settings;
};
services.restic.server = {
enable = true;
dataDir = "/backup";
listenAddress = "127.0.0.1:8000";
appendOnly = true;
};
services.nginx.virtualHosts = my.homelab.services.nginx.virtualHosts;
}

Binary file not shown.

Binary file not shown.

BIN
secrets/morph/restic.nix Normal file

Binary file not shown.

BIN
secrets/morph/serv.nix Normal file

Binary file not shown.

Binary file not shown.

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ config, my, pkgs, ... }:
{
services.postgresql = {
@ -14,4 +14,18 @@
compression = "zstd";
startAt = "*-*-* 04:00:00"; # daily at 04:00
};
users.users.postgres.extraGroups = [ "restic-backup" ];
services.restic.backups.postgresql-15 =
let resticCfg = my.homelab.services.restic;
in {
inherit (resticCfg) environmentFile;
initialize = true;
repository = "${resticCfg.repositoryBase}/${config.networking.hostName}";
passwordFile = "/var/secrets/restic/repo/${config.networking.hostName}";
user = "postgres";
paths = [ "/var/backup/postgresql/all.sql.zstd" ];
timerConfig.OnCalendar = "*-*-* 4:30:00"; # daily at 04:30
};
}