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

63 lines
1.7 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,
...
2025-12-28 13:39:42 +01:00
}:
let
2022-01-19 10:58:44 +01:00
dataDir = "/backup/restic";
2025-12-28 13:39:42 +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;
2025-12-28 13:39:42 +01:00
extraFlags = [ "--no-auth" ]; # auth is done via firewall
listenAddress = toString pkgs.lib.niveum.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";
};
2025-12-28 13:39:42 +01:00
networking.firewall =
let
dport = pkgs.lib.niveum.restic.port;
protocol = "tcp";
rules = [
(pkgs.lib.niveum.firewall.accept {
inherit dport protocol;
source = pkgs.lib.niveum.retiolumAddresses.kabsa.ipv4;
})
(pkgs.lib.niveum.firewall.accept {
inherit dport protocol;
source = pkgs.lib.niveum.retiolumAddresses.manakish.ipv4;
})
(pkgs.lib.niveum.firewall.accept {
inherit dport protocol;
source = pkgs.lib.niveum.retiolumAddresses.makanek.ipv4;
})
(pkgs.lib.niveum.firewall.accept {
inherit dport protocol;
source = pkgs.lib.niveum.retiolumAddresses.fatteh.ipv4;
})
(pkgs.lib.niveum.firewall.accept {
inherit dport protocol;
source = pkgs.lib.niveum.retiolumAddresses.ful.ipv4;
})
];
in
{
extraCommands = pkgs.lib.niveum.firewall.addRules rules;
extraStopCommands = pkgs.lib.niveum.firewall.removeRules rules;
};
2022-01-18 21:29:30 +01:00
}