From e627b2b18b155edc8dfc5b42991d4c2ce120079b Mon Sep 17 00:00:00 2001 From: hk Date: Fri, 9 Jun 2017 12:50:33 +0200 Subject: [PATCH] Add delete-checkpoints mode until borg v1.1.0 is released with automatic checkpoint pruning --- src/borgwrapper.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/borgwrapper.sh b/src/borgwrapper.sh index ac7564f..1e3882a 100755 --- a/src/borgwrapper.sh +++ b/src/borgwrapper.sh @@ -8,7 +8,7 @@ OPTIONS -c CONFIG_FILE MODES - init|backup|verify|unlock|exec + init|backup|verify|unlock|delete-checkpoints|exec EOF } @@ -77,6 +77,14 @@ borg_verify () { ${BORG} check "${BORG_CHECK_ARGS[@]}" "${BORG_REPO}" } +borg_delete_checkpoints () { + ${BORG} list "${BORG_REPO}" \ + | { grep .checkpoint || true; } \ + | cut -d ' ' -f 1 \ + | xargs -I % -n 1 --no-run-if-empty \ + ${BORG} delete "${BORG_REPO}"::% +} + borg_unlock () { # Use if borgbackup is not shut down cleanly and complains about lock files ${BORG} break-lock "${BORG_REPO}" @@ -225,6 +233,8 @@ mkdir -p "${LOCKDIR}" trap 'exit_verify $?' ERR INT TERM borg_verify exit_verify 0 + elif [[ ${MODE} == "delete-checkpoints" ]]; then + borg_delete_checkpoints elif [[ ${MODE} == "unlock" ]]; then borg_unlock elif [[ ${MODE} == "exec" ]]; then