Skip to content

Commit

Permalink
After forget, run prune
Browse files Browse the repository at this point in the history
Thus runs `restic prune`, to remove pack files that are no longer
needed.  However, some wasted space is allowed: The `REPACK_MAX_UNUSED`
environment variable takes a percentage or a number of bytes (with or
without k/m/g suffix); packs are allowed to have that much space unused
before a repack is triggered.

Setting a non-zero number can be good when using a cloud storage
platform that charges for data retrieval, or that charges more for
regularly accessing files (instead of letting them age).
  • Loading branch information
akkornel committed Dec 9, 2023
1 parent 4e9cd26 commit d7c3d97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions root/etc/periodic/15min/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ if [ ${RETAIN_YEARLY:-x} = 'x' ]; then
echo 'RETAIN_YEARLY environment variable is missing!'
exit 1
fi
if [ ${REPACK_MAX_UNUSED:-x} = 'x' ]; then
echo 'REPACK_MAX_UNUSED environment variable is missing!'
exit 1
fi

# PART 1: Dump the database into the Bookstack directory
mysqldump --host=${MYSQL_HOST} --password=$(cat $DB_PASS_FILE) --databases mysql > /bookstack/backups/mysql.sql
Expand All @@ -56,3 +60,7 @@ restic backup \
restic forget --keep-hourly ${RETAIN_HOURLY} --keep-daily ${RETAIN_DAILY} \
--keep-weekly ${RETAIN_WEEKLY} --keep-monthly ${RETAIN_MONTHLY} \
--keep-yearly ${RETAIN_YEARLY}

# PART 4: Prune pack files
echo "Repacking with max-unused of ${REPACK_MAX_UNUSED}"
restic prune --max-unused ${REPACK_MAX_UNUSED}

0 comments on commit d7c3d97

Please sign in to comment.