documentation
This commit is contained in:
		
							
								
								
									
										62
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								README.md
									
									
									
									
									
								
							| @@ -22,39 +22,30 @@ $ cd restic-systemd-automatic-backup | ||||
| $ sudo make install | ||||
| ```` | ||||
|  | ||||
| ### 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. | ||||
| ### 1. Configure the Backup | ||||
|  | ||||
| Take note of the your account ID, application key and password for the next steps. | ||||
| First edit the following Files as you like | ||||
|  | ||||
| * restic-backup.service | ||||
|     * Add your Username  | ||||
| * restic-check.service | ||||
|     * Add your Username | ||||
| * env.sh | ||||
| * pw.txt | ||||
|     * password for your Backup | ||||
|  | ||||
| After that you can copy all files to the right directories with the Makefile in this Repository | ||||
|  | ||||
| ### 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: | ||||
| ```bash | ||||
| $ source /etc/restic/b2_env.sh | ||||
| $ restic snapshots    # You don't have to supply all parameters like --repo, as they are now in your environment! | ||||
| $ sudo make install | ||||
| ```` | ||||
| * `b2_pw.txt`: Put your B2 password in this file. | ||||
|  | ||||
| ### 3. Initialize remote repo | ||||
| Now we must initialize the repository on the remote end: | ||||
| ```bash | ||||
| source /etc/restic/b2_env.sh | ||||
| restic init | ||||
| ``` | ||||
| ### 2. Initialize your 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. | ||||
| See https://restic.readthedocs.io/en/stable/030_preparing_a_new_repo.html for how to do this | ||||
|  | ||||
| Put this file in `/`: | ||||
| * `.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 | ||||
| ### 3. Make first backup & verify | ||||
| Now see if the backup itself works, by running | ||||
|  | ||||
| ```bash | ||||
| @@ -62,14 +53,8 @@ $ /usr/local/sbin/restic_backup.sh | ||||
| $ restic snapshots | ||||
| ```` | ||||
|  | ||||
| ### 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! | ||||
|  | ||||
|  | ||||
| Put these files in `/etc/systemd/system/`: | ||||
| * `restic-backup.service`: A service that calls the backup script. | ||||
| * `restic-backup.timer`: A timer that starts the backup every day. | ||||
|  | ||||
| ### 4. 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 week! | ||||
|  | ||||
| Now simply enable the timer with: | ||||
| ```bash | ||||
| @@ -103,20 +88,7 @@ $ journalctl -f -u restic-backup.service | ||||
| (skip `-f` to see all backups that has run) | ||||
|  | ||||
|  | ||||
|  | ||||
| ### 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`: | ||||
| * `systemd-email`: Sends email using sendmail(1). This script also features time-out for not spamming Gmail servers and getting my account blocked. | ||||
|  | ||||
| Put this files in `/etc/systemd/system/`: | ||||
| * `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. | ||||
|  | ||||
| As you maybe noticed already before, `restic-backup.service` is configured to start `status-email-user.service` on failure. | ||||
|  | ||||
|  | ||||
| ### 8. Optional: automated backup checks | ||||
| ### 5. 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. | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| [Unit] | ||||
| Description=Backup with restic | ||||
| OnFailure=status-email-user@%n.service | ||||
| OnFailure=status-popup-user@%n.service | ||||
|  | ||||
| [Service] | ||||
| Type=simple | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| [Unit] | ||||
| Description=Check restic backup for errors | ||||
| OnFailure=status-email-user@%n.service | ||||
| OnFailure=status-popup-user@%n.service | ||||
| Conflicts=restic.service | ||||
|  | ||||
| [Service] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user