summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2020-01-27 16:53:28 +0100
committerFlorian Pritz <bluewind@xinu.at>2020-01-27 16:53:28 +0100
commitb8c14b1740ac268eb6b4ff56c856ddba1ccfdc2b (patch)
tree44a327ed311e36aba10cdbd5ca50e8e7113cf747
parent51eef1e9d1013186b67f584ba1014add588439e4 (diff)
downloadbin-b8c14b1740ac268eb6b4ff56c856ddba1ccfdc2b.tar.gz
bin-b8c14b1740ac268eb6b4ff56c856ddba1ccfdc2b.tar.xz
backup.sh: Only purge when doing full backups
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xbackup.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/backup.sh b/backup.sh
index a674819..38e2a89 100755
--- a/backup.sh
+++ b/backup.sh
@@ -137,8 +137,13 @@ backup_borg() {
fi
borg create "${options[@]}" "$dst::$backup_prefix-$(date "+%Y%m%d-%H%M%S")" "${src[@]}"
- borg prune --prefix "backup-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
- borg prune --prefix "partial-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+
+ # Only purge when doing full backups. Increases partial backup speed and
+ # ensure that we have at least one recent full backup when we purge.
+ if [[ $backup_prefix == 'backup-' ]]; then
+ borg prune --prefix "backup-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+ borg prune --prefix "partial-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
+ fi
}
### support functions below ###