privatemounts = false is required if snap is separate from the backup service.
This commit is contained in:
parent
e782f7c268
commit
4a4cce4e94
1 changed files with 7 additions and 9 deletions
|
@ -3,9 +3,7 @@
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}: let
|
||||||
|
|
||||||
let
|
|
||||||
cfg = config.mySystem.services.zfs-nightly-snap;
|
cfg = config.mySystem.services.zfs-nightly-snap;
|
||||||
|
|
||||||
# Replaces/Creates and mounts a ZFS snapshot
|
# Replaces/Creates and mounts a ZFS snapshot
|
||||||
|
@ -62,8 +60,7 @@ let
|
||||||
mount | grep "$BACKUP_DIRECTORY"
|
mount | grep "$BACKUP_DIRECTORY"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.mySystem.services.zfs-nightly-snap = {
|
options.mySystem.services.zfs-nightly-snap = {
|
||||||
enable = lib.mkEnableOption "ZFS nightly snapshot service";
|
enable = lib.mkEnableOption "ZFS nightly snapshot service";
|
||||||
|
|
||||||
|
@ -98,12 +95,12 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
# Adding script to system packages
|
# Adding script to system packages
|
||||||
environment.systemPackages = [ resticSnapAndMount ];
|
environment.systemPackages = [resticSnapAndMount];
|
||||||
|
|
||||||
systemd = {
|
systemd = {
|
||||||
# Timer for nightly snapshot
|
# Timer for nightly snapshot
|
||||||
timers.zfs-nightly-snap = {
|
timers.zfs-nightly-snap = {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = ["timers.target"];
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnCalendar = cfg.startAt;
|
OnCalendar = cfg.startAt;
|
||||||
Persistent = true; # Run immediately if we missed the last trigger time
|
Persistent = true; # Run immediately if we missed the last trigger time
|
||||||
|
@ -115,9 +112,10 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "${resticSnapAndMount}/bin/zfs-nightly-snap";
|
ExecStart = "${resticSnapAndMount}/bin/zfs-nightly-snap";
|
||||||
|
PrivateMounts = "no"; # We want to mount the snapshot to the system
|
||||||
};
|
};
|
||||||
requires = [ "zfs.target" ];
|
requires = ["zfs.target"];
|
||||||
after = [ "zfs.target" ];
|
after = ["zfs.target"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue