Modified: README.md

This commit is contained in:
Erik Westrup
2021-12-01 18:05:19 +01:00
parent ae228186eb
commit 213fb95bdc

View File

@@ -16,7 +16,7 @@
<img src = "https://contrib.rocks/image?repo=erikw/restic-systemd-automatic-backup&max=24"/>
</a>
## Restic
# Intro
[restic](https://restic.net/) 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](https://www.backblaze.com/b2/cloud-storage.html) as restic works well with it, and it is (at the time of writing) very affordable for the hobbyist hacker!
@@ -30,7 +30,7 @@ Note, you can use any of the supported [storage backends](https://restic.readthe
# Requirements
* `restic >=v0.9.6`
## Set up
# Set up
Tip: The steps in this section will instruct you to copy files from this repo to system directories. If you don't want to do this manually, you can use the Makefile:
@@ -40,14 +40,14 @@ $ cd restic-systemd-automatic-backup
$ sudo make install
````
### 1. Create Backblaze B2 account
## 1. Create Backblaze B2 account
First, see this official Backblaze [tutorial](https://help.backblaze.com/hc/en-us/articles/115002880514-How-to-configure-Backblaze-B2-with-Restic-on-Linux) on restic, and follow the instructions ("Create Backblaze account with B2 enabled") there on how to create a new B2 bucket.
Take note of the your account ID, application key and password for the next steps.
### 2. Configure your B2 account locally
## 2. Configure your B2 account locally
Put these files in `/etc/restic/`:
* `b2_env.sh`: Fill this file out with your B2 bucket settings etc. The reason for putting these in a separate file is that it can be used also for you to simply source, when you want to issue some restic commands. For example:
```console
@@ -56,14 +56,14 @@ $ restic snapshots # You don't have to supply all parameters like --repo, as
````
* `b2_pw.txt`: This file should contain the restic repository password. This is a new password what soon will be used when initializing the new repository. It should be unique to this restic backup repository and is needed for restoring from it. Don't re-use your b2 login password, this should be different.
### 3. Initialize remote repo
## 3. Initialize remote repo
Now we must initialize the repository on the remote end:
```console
$ source /etc/restic/b2_env.sh
$ restic init
```
### 4. Script for doing the backup
## 4. Script for doing the backup
Put this file 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 backups to save), etc.
@@ -71,7 +71,7 @@ Copy this file to `/etc/restic/backup_exclude` or `~/.backup_exclude`:
* `.backup_exclude`: A list of file pattern paths to exclude from you backups, files that just occupy storage space, backup-time, network and money.
### 5. Make first backup & verify
## 5. Make first backup & verify
Now see if the backup itself works, by running
```console
@@ -79,7 +79,7 @@ $ /usr/local/sbin/restic_backup.sh
$ restic snapshots
````
### 6. Backup automatically; systemd service + timer
## 6. Backup automatically; systemd service + timer
Now we can do the modern version of a cron-job, a systemd service + timer, to run the backup every day!
@@ -121,7 +121,7 @@ $ journalctl -f -u restic-backup.service
### 7. Email notification on failure
## 7. Email notification on failure
We want to be aware when the automatic backup fails, so we can fix it. Since my laptop does not run a mail server, I went for a solution to set up my laptop to be able to send emails with [postfix via my Gmail](https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/). Follow the instructions over there.
Put this file in `/usr/local/sbin`:
@@ -133,19 +133,19 @@ Put this files in `/etc/systemd/system/`:
As you maybe noticed already before, `restic-backup.service` is configured to start `status-email-user.service` on failure.
### 8. Optional: automated backup checks
## 8. Optional: automated backup checks
Once in a while it can be good to do a health check of the remote repository, to make sure it's not getting corrupt. This can be done with `$ restic check`.
There are some `*-check*`-files in this git repo. Install these in the same way you installed the `*-backup*`-files.
## Cron?
# Cron?
If you want to run an all-classic cron job instead, do like this:
* `etc/cron.d/restic`: Depending on your system's cron, put this in `/etc/cron.d/` or similar, or copy the contents to $(sudo crontab -e). The format of this file is tested under FreeBSD, and might need adaptions depending on your cron.
* `usr/local/sbin/cron_mail`: A wrapper for running cron jobs, that sends output of the job as an email using the mail(1) command.
## Uninstall
# Uninstall
There is a make target to remove all files (scripts and configs) that were installed by `sudo make install`. Just run: