fix restic prune

This commit is contained in:
Charlotte 🦝 Delenk 2022-08-26 19:27:47 +01:00
parent 3b0434e2ea
commit 6ed70c8737
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122

View file

@ -4,6 +4,7 @@
... ...
}: let }: let
resticPrunePre = pkgs.writeScript "resticPrunePre" '' resticPrunePre = pkgs.writeScript "resticPrunePre" ''
#!/bin/sh
set -ex set -ex
# Recover from an unclean shutdown # Recover from an unclean shutdown
@ -17,9 +18,9 @@
${pkgs.zfs}/bin/zfs destroy tank/backup-old || true ${pkgs.zfs}/bin/zfs destroy tank/backup-old || true
# Wait for the restic repository to be unlocked # 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 sleep 10
fi done
# Clone the Dataset # Clone the Dataset
${pkgs.zfs}/bin/zfs snapshot tank/backup@prune ${pkgs.zfs}/bin/zfs snapshot tank/backup@prune
@ -27,11 +28,13 @@
chown backup:backup /backup-prune chown backup:backup /backup-prune
''; '';
resticPrune = pkgs.writeScript "resticPrune" '' resticPrune = pkgs.writeScript "resticPrune" ''
#!/bin/sh
export RESTIC_REPOSITORY="$RESTIC_REPOSITORY-prune" export RESTIC_REPOSITORY="$RESTIC_REPOSITORY-prune"
${pkgs.restic}/bin/restic prune --no-cache --max-unused 0 ${pkgs.restic}/bin/restic prune --no-cache --max-unused 0
${pkgs.restic}/bin/restic check --read-data-subset 10% ${pkgs.restic}/bin/restic check --read-data-subset 10%
''; '';
resticPrunePost = pkgs.writeScript "resticPrunePost" '' resticPrunePost = pkgs.writeScript "resticPrunePost" ''
#!/bin/sh
set -ex set -ex
# Wait for the restic repository to be unlocked # Wait for the restic repository to be unlocked