Prune backups

This commit is contained in:
Salt 2025-01-20 20:23:34 -06:00
parent 8e6cbb69ff
commit 5d8238e029

View File

@ -54,9 +54,26 @@ backup() {
for dir in "$@"; do for dir in "$@"; do
echo "- $dir" echo "- $dir"
done done
# Back up everything in the $DIRS array (which was passed as args)
/opt/restic-wrapper \ /opt/restic-wrapper \
backup \ 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 else
dir="$@" dir="$@"
echo "- $dir" echo "- $dir"