nixos/modules/backup/systemd-utils.nix

24 lines
532 B
Nix
Raw Normal View History

{
path,
config,
script,
}:
{
timers."backup-${baseNameOf path}" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5m";
OnCalendar = "* *-*-* 00:00:00";
Unit = "backup-${baseNameOf path}.service";
Persistent = true;
};
};
services."backup-${baseNameOf path}" = {
enable = config.enable;
description = "Saves a directory and its content.";
serviceConfig = {
Type = "simple";
ExecStart = "${script}/bin/backup-${baseNameOf path}.sh";
};
};
}