Skip purged borg backups during backup pruning

We recently updated our borg backup system to support explicit purging
of backups. When purged there are no longer any backups to prune so we
need to skip any backups in this state. Update the pruning script to do
so.

Change-Id: Ib23a72c949c05855176fe54637f406b7797b37ae
This commit is contained in:
Clark Boylan 2024-11-25 09:17:57 -08:00
parent 0ce69e8cb3
commit cb8226128e

View File

@ -26,10 +26,15 @@ pushd /opt/backups
for u in borg-*; do
BORG_BASE=/opt/backups/$u
BORG_REPO=${BORG_BASE}/backup
BORG_RETIRED=${BORG_BASE}/.retired
_prune_flags='--keep-daily 7 --keep-weekly 4 --keep-monthly 12'
_retired=''
if [[ -f ${BORG_BASE}/.retired ]]; then
if [[ -f "${BORG_RETIRED}" ]] && [[ ! -d "${BORG_REPO}" ]]; then
# This repo was retired and purged. We don't need to prune it.
echo "$(date) Skipping ${BORG_REPO} it is retired and purged."
continue
elif [[ -f "${BORG_RETIRED}" ]]; then
_prune_flags='--keep-daily 1'
_retired=' (retired)'
fi