restic is a command-line tool for making backups, the right way. Check the official website for a feature explanation. As a storage backend, I recommend Backblaze B2 as restic works well with it, and it is (at the time of writing) very affordable for the hobbyist hacker!
First, see this official Backblaze tutorial on restic, on how to setup your B2 bucket.
Unfortunately restic does not come per-configured with a way to run automated backups, say every day. However it's possible to set this up yourself using. This example also features email notifications when a backup fails to complete.
Put this file in /etc/restic/
:
b2_env.sh
: Fill this file out with your B2 bucket settings etc. The reason for putting these in a separeate file is that it can be used also for you to simply source, when you want to issue some restic commands. For example:
$ source /etc/restic/b2_env.sh
$ restic snapshots # You don't have to supply all paramters like --repo, as they are now in your envionment!
b2_pw.txt
: Put your b2 password in this file.
Put these files in /usr/local/sbin
:
restic_backup.sh
: A script that defines how to run the backup. Edit this file to respect your needs in terms of backup which paths to backup, retention (number of bakcups to save), etc.systemd-email
: Sends email using sendmail. You must set up your computer so it can send mail, for example using postfix and Gmail. This script also features time-out for not spamming Gmail servers.
Put these files in /etc/systemd/system/
:
restic-backup.service
: A service that calls the script above.restic-backup.timer
: A timer (systemd's cronjobs) that starts the backup every day.status-email-user@.service
: A service that can notify you via email when a systemd service fails. Edit the target email address in this file.
Now simply enable the timer with:
$ systemctl enable restic-backup.timer
and enjoy your computer being backed up every day!
You can see when your next backup will be schedued
$ systemctl list-timers | grep restic
Furthermore there are some *-check*
-files in this repo too. Install these too if you want to run restic-check once in a while to verify that your remote backup is not corrupt.