nixfiles/profiles/pipedCluster/restic.nix

45 lines
1 KiB
Nix

{
self,
pkgs,
config,
...
}: let
secrets = config.services.secrets.secrets;
clusterConfig = import "${self}/data/piped/pipedClusterConfig.nix";
currentHostConfig = clusterConfig.hosts.${config.networking.hostName};
inherit (currentHostConfig) resticName resticBucket;
in {
environment.systemPackages = with pkgs; [
restic
(pkgs.writeShellScriptBin "restic-${resticName}" ''
env \
RESTIC_PASSWORD_FILE=${secrets.restic_password.path} \
$(cat ${secrets.restic_env.path}) \
${pkgs.restic}/bin/restic $@
'')
];
services.restic.backups.${resticName} = {
user = "root";
paths = [
"/var/lib/cockroachdb"
"/var/lib/cockroachdb-certs"
];
repository = "rest:https://storage-restic.owo.monster/${resticBucket}";
passwordFile = "${secrets.restic_password.path}";
environmentFile = "${secrets.restic_env.path}";
pruneOpts = [
"--keep-last 5"
];
timerConfig = {
OnBootSec = "1m";
OnCalendar = "daily";
};
};
}