From b9d98cca21c1c06d72e1c7d4bd94dd17a2d3a7e8 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 3 Nov 2021 12:39:10 +1100 Subject: [PATCH] borg-backup: skip .checkpoint archives We may see an archive with ".checkpoint" on the end, as described in [1]; the short version is this that borg stamps this every 30 minutes and may appear if a long backup is interrupted. Skip this when making the list of archives to prune. We noticed this on wiki-test; for clarity the list of archives looks like ... wiki-upgrade-test-filesystem-2021-02-16T02:56:09.checkpoint Tue, 2021-02-16 02:56:11 [c444a0765e5791f3f68f08624d1efd80bf8a3ebc96bb225f08e4013befa2b460] wiki-upgrade-test-filesystem-2021-02-16T17:45:04 Tue, 2021-02-16 17:45:06 [b901b55ac3bf9abecba024caebad5ba7cd1a966e3f00b366f6cff45feba7bdff] wiki-upgrade-test-mysql-2021-02-16T18:35:09 Tue, 2021-02-16 18:35:11 [1d38cd3b4b1b3927b543e4ccc6c794cd3a513a70979ff025bbf303e1fe5e490f] wiki-upgrade-test-filesystem-2021-02-17T17:45:05 Wed, 2021-02-17 17:45:07 [f665e275c0014a21b82efaece5d36525a4ce6cb423253d5bd0b1323b230fa53a] ... [1] https://borgbackup.readthedocs.io/en/stable/faq.html#if-a-backup-stops-mid-way-does-the-already-backed-up-data-stay-there Change-Id: Ia33f46305ef8f541efb7c7150d4bb2e977b01d46 --- .../roles/borg-backup-server/files/prune-borg-backups.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh b/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh index 0ed9142b5a..af6b684dc6 100644 --- a/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh +++ b/playbooks/roles/borg-backup-server/files/prune-borg-backups.sh @@ -28,7 +28,9 @@ for u in borg-*; do # Look at all archives and strip the timestamp, leaving just the archive names # We limit the prune by --prefix so each archive is considered separately - archives=$(/opt/borg/bin/borg list ${BORG_REPO} | awk '{$1 = substr($1, 0, length($1)-20); print $1}' | sort | uniq) + # Long-running aborted backups might leave a ".checkpoint" archive around; ignore + # these as prune will remove them automatically + archives=$(/opt/borg/bin/borg list ${BORG_REPO} | awk '$1 !~ /\.checkpoint$/ { print substr($1, 0, length($1)-20) }' | sort | uniq) for prefix in ${archives}; do