From 6ed70c8737ca6567349e81f258a4de6d76ecc9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Fri, 26 Aug 2022 19:27:47 +0100 Subject: [PATCH] fix restic prune --- config/services/backup.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/services/backup.nix b/config/services/backup.nix index c60a86d0..d766e1c6 100644 --- a/config/services/backup.nix +++ b/config/services/backup.nix @@ -4,6 +4,7 @@ ... }: let resticPrunePre = pkgs.writeScript "resticPrunePre" '' + #!/bin/sh set -ex # Recover from an unclean shutdown @@ -17,9 +18,9 @@ ${pkgs.zfs}/bin/zfs destroy tank/backup-old || true # Wait for the restic repository to be unlocked - while [ -n "$(${pkgs.restic}/bin/restic list locks)" ]; then + while [ -n "$(${pkgs.restic}/bin/restic list locks)" ]; do sleep 10 - fi + done # Clone the Dataset ${pkgs.zfs}/bin/zfs snapshot tank/backup@prune @@ -27,11 +28,13 @@ chown backup:backup /backup-prune ''; resticPrune = pkgs.writeScript "resticPrune" '' + #!/bin/sh export RESTIC_REPOSITORY="$RESTIC_REPOSITORY-prune" ${pkgs.restic}/bin/restic prune --no-cache --max-unused 0 ${pkgs.restic}/bin/restic check --read-data-subset 10% ''; resticPrunePost = pkgs.writeScript "resticPrunePost" '' + #!/bin/sh set -ex # Wait for the restic repository to be unlocked