1
0
Fork 1
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:
blargg 2021-05-17 18:54:13 -07:00 committed by Felix Buehler
parent 1ea75adb02
commit 697198834c

View file

@ -102,6 +102,14 @@ let
inherit (cfg) startAt; inherit (cfg) startAt;
}; };
mkBackupTimers = name: cfg:
nameValuePair "borgbackup-job-${name}" {
description = "BorgBackup job ${name} timer";
timerConfig = {
Persistent = cfg.persistentTimer;
};
};
# utility function around makeWrapper # utility function around makeWrapper
mkWrapperDrv = { mkWrapperDrv = {
original, name, set ? {} 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 { user = mkOption {
type = types.str; type = types.str;
description = '' description = ''
@ -695,6 +716,9 @@ in {
# A repo named "foo" is mapped to systemd.services.borgbackup-repo-foo # A repo named "foo" is mapped to systemd.services.borgbackup-repo-foo
// mapAttrs' mkRepoService repos; // 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); users = mkMerge (mapAttrsToList mkUsersConfig repos);
environment.systemPackages = with pkgs; [ borgbackup ] ++ (mapAttrsToList mkBorgWrapper jobs); environment.systemPackages = with pkgs; [ borgbackup ] ++ (mapAttrsToList mkBorgWrapper jobs);