diff --git a/nixos/modules/services/backup/syncoid.nix b/nixos/modules/services/backup/syncoid.nix index 8bfb3d70a6e6..da5a21b37fb7 100644 --- a/nixos/modules/services/backup/syncoid.nix +++ b/nixos/modules/services/backup/syncoid.nix @@ -362,7 +362,6 @@ in { description = "Syncoid ZFS synchronization from ${c.source} to ${c.target}"; after = [ "zfs.target" ]; - startAt = cfg.interval; # syncoid may need zpool to get feature@extensible_dataset path = [ "/run/booted-system/sw/bin/" ]; serviceConfig = { @@ -473,6 +472,23 @@ in ] ) ) cfg.commands; + + systemd.timers = lib.concatMapAttrs ( + name: c: + lib.optionalAttrs + (config.systemd.services."syncoid-${escapeUnitName name}".enable && cfg.interval != [ ]) + { + "syncoid-${escapeUnitName name}" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = cfg.interval; + # Backup timers should catch up on missed windows (e.g. the + # machine was powered off), like restic and btrbk do. + Persistent = true; + }; + }; + } + ) cfg.commands; }; meta.maintainers = with lib.maintainers; [