2023-08-01 22:06:30 +01:00
|
|
|
{
|
2023-09-21 05:06:27 +01:00
|
|
|
self,
|
2023-08-01 22:06:30 +01:00
|
|
|
pkgs,
|
2023-09-19 17:53:44 +01:00
|
|
|
config,
|
2023-08-01 22:06:30 +01:00
|
|
|
...
|
|
|
|
}: let
|
2023-09-19 17:53:44 +01:00
|
|
|
secrets = config.services.secrets.secrets;
|
2023-09-21 05:06:27 +01:00
|
|
|
|
|
|
|
clusterConfig = import "${self}/data/piped/pipedClusterConfig.nix";
|
|
|
|
|
|
|
|
currentHostConfig = clusterConfig.hosts.${config.networking.hostName};
|
|
|
|
inherit (currentHostConfig) resticName resticBucket;
|
2023-08-01 22:06:30 +01:00
|
|
|
in {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
restic
|
2023-09-21 05:06:27 +01:00
|
|
|
(pkgs.writeShellScriptBin "restic-${resticName}" ''
|
2023-08-01 22:06:30 +01:00
|
|
|
env \
|
2023-09-19 17:53:44 +01:00
|
|
|
RESTIC_PASSWORD_FILE=${secrets.restic_password.path} \
|
|
|
|
$(cat ${secrets.restic_env.path}) \
|
2023-08-01 22:06:30 +01:00
|
|
|
${pkgs.restic}/bin/restic $@
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2023-09-21 05:06:27 +01:00
|
|
|
services.restic.backups.${resticName} = {
|
2023-08-01 22:06:30 +01:00
|
|
|
user = "root";
|
|
|
|
paths = [
|
2023-09-18 03:56:58 +01:00
|
|
|
"/var/lib/cockroachdb"
|
|
|
|
"/var/lib/cockroachdb-certs"
|
2023-08-01 22:06:30 +01:00
|
|
|
];
|
|
|
|
|
2023-09-21 05:06:27 +01:00
|
|
|
repository = "rest:https://storage-restic.owo.monster/${resticBucket}";
|
2023-09-19 17:53:44 +01:00
|
|
|
passwordFile = "${secrets.restic_password.path}";
|
|
|
|
environmentFile = "${secrets.restic_env.path}";
|
2023-08-01 22:06:30 +01:00
|
|
|
|
|
|
|
pruneOpts = [
|
|
|
|
"--keep-last 5"
|
|
|
|
];
|
|
|
|
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = "1m";
|
|
|
|
OnCalendar = "daily";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|