1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/systems/zaatar/backup.nix

62 lines
1.5 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
config,
2022-03-10 21:52:12 +01:00
pkgs,
lib,
...
}: let
niveumLib = import ../../lib;
inherit (niveumLib) retiolumAddresses restic;
2022-01-18 21:29:30 +01:00
firewall = niveumLib.firewall lib;
2022-01-19 10:58:44 +01:00
dataDir = "/backup/restic";
2022-03-10 21:52:12 +01:00
in {
2022-01-18 21:29:30 +01:00
services.restic.server = {
enable = true;
appendOnly = true;
2022-01-19 10:58:44 +01:00
inherit dataDir;
2022-01-18 21:29:30 +01:00
prometheus = true;
2022-03-10 21:52:12 +01:00
extraFlags = ["--no-auth"]; # auth is done via firewall
2024-06-07 11:14:23 +02:00
listenAddress = toString restic.port;
2022-01-18 21:29:30 +01:00
};
2022-01-19 10:58:44 +01:00
environment.systemPackages = [
(pkgs.writers.writeDashBin "restic-niveum" ''
exec ${pkgs.util-linux}/bin/runuser -u restic -g restic -- ${pkgs.restic}/bin/restic -r ${toString dataDir} -p ${config.age.secrets.restic.path} "$@"
2022-01-19 10:58:44 +01:00
'')
];
fileSystems."/backup" = {
2024-04-25 08:45:08 +02:00
device = "/dev/disk/by-id/ata-WDC_WD10JPVX-22JC3T0_WD-WXD1E5510MKW";
fsType = "ext4";
};
2022-03-10 21:52:12 +01:00
networking.firewall = let
dport = restic.port;
2022-01-18 21:29:30 +01:00
protocol = "tcp";
rules = [
2022-03-10 21:52:12 +01:00
(firewall.accept {
inherit dport protocol;
source = retiolumAddresses.kabsa.ipv4;
})
(firewall.accept {
inherit dport protocol;
source = retiolumAddresses.manakish.ipv4;
})
(firewall.accept {
inherit dport protocol;
source = retiolumAddresses.makanek.ipv4;
})
(firewall.accept {
inherit dport protocol;
source = retiolumAddresses.fatteh.ipv4;
})
2023-02-16 08:52:54 +01:00
(firewall.accept {
inherit dport protocol;
source = retiolumAddresses.ful.ipv4;
})
2022-01-18 21:29:30 +01:00
];
in {
extraCommands = firewall.addRules rules;
extraStopCommands = firewall.removeRules rules;
};
}