From 5d8238e0294556686840b001b5d1b0fd7bc51ef6 Mon Sep 17 00:00:00 2001 From: Jacob Babor Date: Mon, 20 Jan 2025 20:23:34 -0600 Subject: [PATCH] Prune backups --- roles/backup/templates/s3backup.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/roles/backup/templates/s3backup.sh b/roles/backup/templates/s3backup.sh index 0197c21..15376be 100644 --- a/roles/backup/templates/s3backup.sh +++ b/roles/backup/templates/s3backup.sh @@ -54,9 +54,26 @@ backup() { for dir in "$@"; do echo "- $dir" done + # Back up everything in the $DIRS array (which was passed as args) /opt/restic-wrapper \ backup \ "$@" + # In addition, we should also prune our backups + # https://restic.readthedocs.io/en/stable/060_forget.html + # --keep-daily n Keeps daily backups for the last n days + # --keep-weekly n Keeps weekly backups for the last n weeks + # --keep-montly n Keeps monthly backups for the last n months + # --keep-tag foo Keeps all snapshots tagged with "foo" + # --host "$HOSTNAME" Only act on *our* snapshots. We don't care about other machines' + # --prune Remove orphaned blobs when we remove snapshots + /opt/restic-wrapper \ + forget \ + --keep-daily 7 \ + --keep-weekly 4 \ + --keep-monthly 6 \ + --keep-tag noremove \ + --host "$HOSTNAME" \ + --prune else dir="$@" echo "- $dir"