nixos/modules/restic-server-client/default.nix

35 lines
944 B
Nix
Raw Normal View History

2022-02-28 19:03:37 +01:00
{ config, inputs, custom, pkgs, time, ... }:
2022-01-29 15:31:42 +01:00
{
2022-02-28 18:19:50 +01:00
systemd.timers."restic-backups-${custom.username}" = {
wantedBy = [ "timers.target" ];
partOf = [ "restic-backups-${custom.username}.service" ];
timerConfig = {
OnCalendar = time;
};
};
2022-02-28 18:19:50 +01:00
systemd.services."restic-backups-${custom.username}" = {
2022-02-28 17:14:57 +01:00
serviceConfig = {
2022-02-28 18:30:59 +01:00
User = "root";
2022-02-28 17:14:57 +01:00
Type = "oneshot";
};
2022-02-28 18:19:50 +01:00
environment = {
RESTIC_PASSWORD_FILE = "/home/${custom.username}/.nixos/secrets/passwords/restic.key";
RESTIC_REPOSITORY = "rest:http://10.7.89.30:8000";
};
script = ''
${pkgs.restic}/bin/restic \
2022-02-28 18:19:50 +01:00
--exclude-file=${inputs.self}/modules/restic/excludes.txt \
backup /home/${custom.username} \
${pkgs.restic}/bin/restic \
forget \
2022-02-28 17:32:55 +01:00
--host ${config.networking.hostName} \
--keep-daily 7 \
--keep-weekly 5 \
--keep-monthly 12 \
--keep-yearly 75 \
'';
2022-01-29 15:31:42 +01:00
};
}