2022-02-21 11:36:12 +01:00
|
|
|
{ inputs, custom, pkgs, ... }:
|
2022-02-28 16:23:03 +01:00
|
|
|
let
|
|
|
|
repository = "rest:http://10.7.89.30:8000";
|
|
|
|
in
|
2021-11-28 12:00:58 +01:00
|
|
|
{
|
2022-01-29 16:01:27 +01:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
restic
|
|
|
|
];
|
|
|
|
|
2022-02-21 11:36:12 +01:00
|
|
|
services.restic.backups.${custom.username} = {
|
|
|
|
user = custom.username;
|
2022-02-28 16:23:03 +01:00
|
|
|
repository = repository;
|
2022-01-29 16:01:27 +01:00
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "hourly";
|
|
|
|
RandomizedDelaySec = "15min";
|
|
|
|
};
|
2022-02-21 11:36:12 +01:00
|
|
|
passwordFile = "/home/${custom.username}/.nixos/secrets/passwords/restic.key";
|
|
|
|
paths = [ "/home/${custom.username}/" ];
|
2021-11-28 12:00:58 +01:00
|
|
|
extraBackupArgs = [
|
2022-02-16 22:19:13 +01:00
|
|
|
"--exclude-file=${inputs.self}/modules/restic/excludes.txt"
|
2021-11-28 12:00:58 +01:00
|
|
|
];
|
|
|
|
};
|
2022-02-28 16:23:03 +01:00
|
|
|
|
|
|
|
systemd.services.prune-restic = {
|
2022-02-28 16:56:32 +01:00
|
|
|
User = custom.username;
|
2022-02-28 16:23:03 +01:00
|
|
|
serviceConfig.Type = "oneshot";
|
2022-02-28 16:56:32 +01:00
|
|
|
After = "restic-backups-${custom.username}.service";
|
2022-02-28 16:23:03 +01:00
|
|
|
script = ''
|
|
|
|
${pkgs.restic}/bin/restic \
|
|
|
|
--repo ${repository} \
|
|
|
|
--password-file "/home/${custom.username}/.nixos/secrets/passwords/restic.key" \
|
|
|
|
forget \
|
|
|
|
--keep-hourly 25 \
|
|
|
|
--keep-daily 7 \
|
|
|
|
--keep-weekly 5 \
|
|
|
|
--keep-monthly 12 \
|
|
|
|
--keep-yearly 75 \
|
|
|
|
'';
|
|
|
|
};
|
2021-11-28 12:00:58 +01:00
|
|
|
}
|