Restic backups

Important data is backed up to Backblaze B2 using restic. This file describes the general configuration, individual systems may introduce certain changes, though. Check the docs for those systems.

Installation and repo setup #

First, create a new bucket (private, disable object lock). Then on the Application Keys page, create a new key (only allow access to the bucket in question, read/write).

Then, create a file ~/ like so:

export RESTIC_REPOSITORY=b2:<bucket name>:restic-repo
export B2_ACCOUNT_ID=abc # Choose a new password and save it in 1Password.
export B2_ACCOUNT_KEY=def


apt install restic

source ~/
restic init

Scripts #

Create a file ~/ like so:


set -e

source /root/

# Optional: Run a backup script or similar here.

BACKUPDIR="<full path to folder>"

restic backup "$BACKUPDIR"
rm -rf "$BACKUPDIR"

Create a file ~/ like so, optionally modifying the numbers:


set -e

source /root/

restic forget --prune --keep-last 7 --keep-daily 7 --keep-weekly 8 --keep-monthly 3 --keep-yearly 2

restic check

Make the scripts executable (chmod +x ~/ && chmod +x ~/

Do a test run of the backup script: ~/ And the cleanup script: ~/

Cronjob #

Create two new checks on Then, add the following lines to the crontab using crontab -e but set different times:

30 5 * * * m=$(/root/ 2>&1) ; curl -fsS -m 30 --retry 5 --data-raw "$m"<healthcheck_ID_1>/$?
00 8 * * 2 m=$(/root/ 2>&1) ; curl -fsS -m 30 --retry 5 --data-raw "$m"<healthcheck_ID_2>/$?