2024-09-28 15:14:40 +02:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
port = "8090";
|
|
|
|
in {
|
2024-09-30 16:06:17 +02:00
|
|
|
services.restic.server = lib.mkIf (inputs ? nix-secrets) {
|
2024-09-28 15:14:40 +02:00
|
|
|
enable = true;
|
|
|
|
appendOnly = true;
|
|
|
|
dataDir = "/backup/restic";
|
|
|
|
listenAddress = "127.0.0.1:${port}";
|
|
|
|
};
|
2024-09-30 16:06:17 +02:00
|
|
|
services.nginx.virtualHosts."restic.venberg.xyz" = {
|
2024-09-28 15:14:40 +02:00
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:${port}";
|
|
|
|
};
|
|
|
|
};
|
2024-09-30 16:06:17 +02:00
|
|
|
sops = lib.mkIf (inputs ? nix-secrets) {
|
|
|
|
secrets.restic-server-credentials = {
|
|
|
|
sopsFile = "${inputs.nix-secrets}/restic-server";
|
|
|
|
format = "binary";
|
|
|
|
path = "/backup/restic/.htpasswd";
|
2024-10-21 16:06:30 +02:00
|
|
|
owner = "restic";
|
2024-09-30 16:06:17 +02:00
|
|
|
};
|
2024-10-18 15:21:37 +02:00
|
|
|
secrets.restic-url = {
|
|
|
|
sopsFile = "${inputs.nix-secrets}/restic-client.yaml";
|
|
|
|
owner = config.host.user;
|
|
|
|
};
|
|
|
|
secrets.restic-password = {
|
|
|
|
sopsFile = "${inputs.nix-secrets}/restic-client.yaml";
|
|
|
|
owner = config.host.user;
|
|
|
|
};
|
2024-09-30 16:06:17 +02:00
|
|
|
};
|
2024-10-18 15:21:37 +02:00
|
|
|
|
2024-09-30 16:06:17 +02:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
restic
|
|
|
|
];
|
2024-10-18 15:21:37 +02:00
|
|
|
|
|
|
|
services.restic.backups = lib.mkIf (inputs ? nix-secrets) {
|
|
|
|
remote = {
|
|
|
|
repositoryFile = config.sops.secrets.restic-url.path;
|
|
|
|
passwordFile = config.sops.secrets.restic-password.path;
|
|
|
|
initialize = true;
|
|
|
|
paths = [
|
|
|
|
"/storage/syncthing"
|
2024-10-19 22:08:48 +02:00
|
|
|
"/storage/factorio"
|
2024-10-18 15:21:37 +02:00
|
|
|
];
|
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "daily";
|
|
|
|
Persistent = true;
|
|
|
|
RandomizedDelaySec = "4h";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-09-28 15:14:40 +02:00
|
|
|
}
|