Borg Backup
In order to create offsite backups for my various self-hosted services I use BorgBackup. It is heavily inspired by their Automating backups article.
Setup
Download this backup script
and place it in /bin/borg-backup
.
This script supports adding a
.nobackup
file to a directory to avoid backing it up.
First, create the borg repository. This command will prompt you for a passphrase to encrypt the backup with.
borg init --encryption=repokey /path/to/repo.borg
Create a cronjob with sudo crontab -e
to run this script at some interval:
0 17 * * * export BORG_PASSPHRASE=password; borg-backup /path/to/repo.borg /path/to/dir
Backblaze B2
I use the following naming structure for B2 buckets and Borg repositories:
- Borg repository:
service-name.borg
- Bucket name:
service-name-borg
Create a script at /bin/rclone-sync
with the contents:
#!/bin/sh
rclone sync "/mnt/backup/$1.borg" "backblaze-$1:$1-borg"
To sync these Borg repositories to Backblaze B2 I use Rclone in a crontab with the following:
0 19 * * * export RCLONE_CONFIG_PASS=CONFIG_PASS; rclone-sync service-name
This will sync the service-name.borg
repo to the bucket service-name-borg
in B2.