1
0
Fork 0
forked from lukas/nixos-config
nixos-config/hosts/blunix/localServices/restic.nix
pijukka 3a68d667ef auto
2025-07-06 20:46:19 +02:00

44 lines
963 B
Nix

{config, pkgs, ...}:
{
services.restic = {
backups = {
vpsBackup = {
user = "root";
paths = [
"/var/lib/private/lldap"
"/var/lib/headscale"
];
passwordFile = config.age.secrets.resticPW.path;
repository = "/backup";
initialize = true;
timerConfig = {
OnCalendar = "03:00";
RandomizedDelaySec = "30min";
};
};
};
};
systemd.services."restore-vps" = {
script = ''
set -e
systemctl stop lldap
systemctl stop headscale
rm -rf /var/lib/private/lldap
rm -rf /var/lib/headscale
${pkgs.restic}/bin/restic restore latest --target /
systemctl start lldap
systemctl start headscale
'';
serviceConfig = {
Type = "oneshot";
User = "root";
Environment = [
"RESTIC_PASSWORD_FILE=${config.age.secrets.resticPW.path}"
"RESTIC_REPOSITORY=/backup"
];
};
};
}