mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-20 04:31:52 +00:00
nixos/borgbackup: Add a persistentTimer option.
Persistent starts the backup service on power on if it was missed while the system was powered down, for example.
This commit is contained in:
parent
1ea75adb02
commit
697198834c
|
@ -102,6 +102,14 @@ let
|
|||
inherit (cfg) startAt;
|
||||
};
|
||||
|
||||
mkBackupTimers = name: cfg:
|
||||
nameValuePair "borgbackup-job-${name}" {
|
||||
description = "BorgBackup job ${name} timer";
|
||||
timerConfig = {
|
||||
Persistent = cfg.persistentTimer;
|
||||
};
|
||||
};
|
||||
|
||||
# utility function around makeWrapper
|
||||
mkWrapperDrv = {
|
||||
original, name, set ? {}
|
||||
|
@ -321,6 +329,19 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
persistentTimer = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
example = true;
|
||||
description = literalDocBook ''
|
||||
Set the <literal>persistentTimer</literal> option for the
|
||||
<citerefentry><refentrytitle>systemd.timer</refentrytitle>
|
||||
<manvolnum>5</manvolnum></citerefentry>
|
||||
which triggers the backup immediately if the last trigger
|
||||
was missed (e.g. if the system was powered down).
|
||||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
|
@ -695,6 +716,9 @@ in {
|
|||
# A repo named "foo" is mapped to systemd.services.borgbackup-repo-foo
|
||||
// mapAttrs' mkRepoService repos;
|
||||
|
||||
# A job named "foo" is mapped to systemd.timers.borgbackup-job-foo
|
||||
systemd.timers = mapAttrs' mkBackupTimers jobs;
|
||||
|
||||
users = mkMerge (mapAttrsToList mkUsersConfig repos);
|
||||
|
||||
environment.systemPackages = with pkgs; [ borgbackup ] ++ (mapAttrsToList mkBorgWrapper jobs);
|
||||
|
|
Loading…
Reference in a new issue