Recently, I did myself a favor and bought a little Beelink SER5 Pro Mini PC a home server to run some services I use on my home network and also to run some development containers.
With this shiny new home server, I also wanted to set up some offsite backups for it. I asked on Mastodon for suggestions and got tips to use borgbackup and restic. Both are reasonable suggestions with great documentation.
After some research, I decided to go with restic and resticprofile. The deciding factor was that Hetzner, whose new S3-compatible object storage I wanted to use, had a documentation for using restic.
Installing restic and resticprofile
I run Debian Bookworm on my home server, so the installation of restic was pretty easy with apt install restic. To install resticprofile, I used the guide for linux and ran the following commands:
curl -LO https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh
chmod +x install.sh
sudo ./install.sh -b /usr/local/bin
Configuring backups
First off, I had to configure S3 credentials and set up a S3 bucket on the Hetzner cloud.
Depending on the location chosen, the endpoint is one of
- fsn1.your-objectstorage.com (Falkenstein)
- nbg1.your-objectstorage.com (Nuremberg)
- hel1.your-objectstorage.com (Helsinki)
My server has just a small 500 GB SSD disk so far, so I decided to go with a single backup configuration that backups the whole device with some exceptions. The backup is scheduled at midnight and the cleanup process at half past midnight.
The configuration file is pretty straightforward and easy. I placed it in the one of the default locations /usr/local/etc/resticprofile/profiles.yaml.
# yaml-language-server: $schema=https://creativeprojects.github.io/resticprofile/jsonschema/config-1.json
version: '1'
default:
repository: 's3:https://<Endpoint of the bucket>/<Name of the S3 Bucket>'
initialize: true
env:
AWS_ACCESS_KEY_ID: <Your Access Key>
AWS_SECRET_ACCESS_KEY: <Your Secret Key>
RESTIC_PASSWORD: <Some long and cryptic string>
backup:
source:
- /
exclude:
- /dev
- /media
- /mnt
- /proc
- /run
- /sys
- /tmp
- /var/cache
- /var/lib/docker
- .cache
schedule-permission: system
schedule-log: "/var/log/resticprofile/homeserver-backup.log"
# Every day at midnight
schedule: "*-*-* 00:00:00"
forget:
# Keep the last 10 snapshots
keep-last: 10
prune: true
schedule-permission: system
schedule-log: "/var/log/resticprofile/homeserver-forget.log"
# Every day at half past midnight
schedule: "*-*-* 00:30:00"
Initialize and do your first backup
To do the initialization of the repository and run my first backup, I had to call the following two commands.
resticprofile init
resticprofile backup
Scheduling backups
Finally, a lazy guy like me wants a regular process for his backup. resticprofile has a handy command to install a scheduler for me that obeys the rules configured in the profiles.yaml
above.
resticprofile schedule
Done!