From 0c37b520334f006b354d5035fc0f01944868fad9 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Mon, 26 Aug 2024 13:16:47 +0200 Subject: [PATCH] backup: fix repository not being unmounted This mounts the backup in a detached mount namespace, the mountpoint is automatically unmounted when the process exits. --- jobs.nix | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/jobs.nix b/jobs.nix index 6073223..b131a4e 100644 --- a/jobs.nix +++ b/jobs.nix @@ -56,14 +56,6 @@ with lib; ''; }; - systemd.mounts = lib.singleton - { - description = "backup volume"; - what = "/dev/mapper/backup-maxwell"; - where = "/mnt/backup"; - partOf = [ "backup.service" ]; - }; - systemd.services.backup = let saved = pkgs.writeText "backup-saved" '' @@ -82,25 +74,24 @@ with lib; in { description = "system backup"; - after = [ "mnt-backup.mount" ]; - requires = [ "mnt-backup.mount" ]; startAt = "*-*-* 03:00"; # every day at 3:00 onFailure = [ "notify-failed@backup.service" ]; serviceConfig = { Type = "oneshot"; PrivateTmp = true; + PrivateMounts = true; LimitNOFILE = 65536; }; environment.BUP_DIR = "/mnt/backup"; - path = with pkgs; [ bup git nfs-utils sudo gzip postgresql ]; + path = with pkgs; [ bup git util-linux sudo gzip postgresql ]; script = '' # mount repository - mkdir -p "$BUP_DIR" + mount -m -L backup "$BUP_DIR" - # init backup + # init backup, if empty ! test -e $BUP_DIR/bupindex && bup init # build indices and save