2024-09-14 08:33:01 +00:00
|
|
|
{ config, ... }:
|
2024-09-23 12:17:26 +00:00
|
|
|
let
|
|
|
|
mkPrune = user: host: {
|
|
|
|
name = "${user}-${host}-prune";
|
|
|
|
value = {
|
|
|
|
user = "restic";
|
|
|
|
repository = "/var/lib/restic/${user}/${host}";
|
|
|
|
passwordFile = "/var/lib/restic/localpass";
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "02:05";
|
|
|
|
RandomizedDelaySec = "1h";
|
|
|
|
};
|
|
|
|
pruneOpts = [
|
|
|
|
"--keep-daily 7"
|
|
|
|
"--keep-weekly 5"
|
|
|
|
"--keep-monthly 12"
|
|
|
|
"--keep-yearly 75"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
in
|
2024-09-14 08:33:01 +00:00
|
|
|
{
|
|
|
|
services.restic.server = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/restic";
|
|
|
|
listenAddress = "127.0.0.1:19573";
|
2024-09-23 12:17:26 +00:00
|
|
|
privateRepos = true;
|
2024-09-14 08:33:01 +00:00
|
|
|
extraFlags = [
|
|
|
|
"--append-only"
|
2024-09-23 12:17:26 +00:00
|
|
|
"--prometheus-no-auth"
|
2024-09-14 08:33:01 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-09-23 12:17:26 +00:00
|
|
|
services.restic.backups = builtins.listToAttrs [
|
|
|
|
(mkPrune "xin" "calcite")
|
|
|
|
(mkPrune "xin" "massicot")
|
|
|
|
];
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 8443 ];
|
2024-09-14 08:33:01 +00:00
|
|
|
|
|
|
|
services.caddy.virtualHosts."https://backup.xinyang.life:8443".extraConfig = ''
|
|
|
|
reverse_proxy ${config.services.restic.server.listenAddress}
|
|
|
|
'';
|
|
|
|
}
|