24 lines
532 B
Nix
24 lines
532 B
Nix
{
|
|
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";
|
|
};
|
|
};
|
|
}
|