Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peterrus/restic-wrapper
Simple bash wrapper to source .env configuration files for Restic. Facilitates both manual CLI execution and scheduled (cron) execution.
https://github.com/peterrus/restic-wrapper
backup bash restic restic-script
Last synced: about 1 month ago
JSON representation
Simple bash wrapper to source .env configuration files for Restic. Facilitates both manual CLI execution and scheduled (cron) execution.
- Host: GitHub
- URL: https://github.com/peterrus/restic-wrapper
- Owner: peterrus
- Created: 2021-02-14T09:49:17.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-21T15:17:04.000Z (over 2 years ago)
- Last Synced: 2024-10-30T14:26:33.592Z (about 1 month ago)
- Topics: backup, bash, restic, restic-script
- Language: Shell
- Homepage:
- Size: 22.5 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-restic - restic-wrapper - Simple bash wrapper to source .env configuration files for Restic (and optionally rclone). (Wrappers)
README
# Restic Backup Wrapper
This wrapper attempts to make running restic a bit easier. It reads configuration files (in the form of `.env` files) and provides shortcuts to be used in manual and automated (cronjob's) situations alike. I tried to keep the script as simple as possible so you can hack on it to suit your needs. Notifications about the result of a backup job are handled by calling a script called `restic_notify`. The one provided in this repository sends mail over SMTP.
This script should work without problems on most linux distributions. I can not vouch for OSX but feedback is welcome.
## Setup
After checking out this repo (or just downloading the script) create config files in the `configs/` directory. There is already an example in this directory. The file name of the `.env` file dictates the 'job name'. You will need this later. Please be aware that you currently need to create an `excludefile` even if you are not using any excludes. This file can be empty.
(See [Restic Docs](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files) for examples)
When you have created the config files it might be wise to back them up for safekeeping using `./restic_wrapper -a export-config`.
If you have not initialized a Restic repository at the location you set in `RESTIC_REPOSITORY` be sure to create one using `./restic_wrapper -b example-job -a run -r init`.
You are now ready to use the wrapper. See `./restic_wrapper` (without parameters) for all options.
## Notifications
By default restic-wrapper outputs all status information to the terminal. You can route that output to the `restic_notify` script by providing the `-m` flag like so: `./restic_wrapper -b example-job -a backup -m`.
The `restic_notify` script in this repository sends email over SMTP and sets the subject according to whether or not the backup job succeeded. Mail is sent using `s-nail` so be sure to install that on your system.
See `configs/smtp.env.example` and rename it to `configs/smtp.env`.
## Scheduled execution
You can set up a cronjob for (for example) nightly backups at 3:30.```
30 3 * * * ~/restic_wrapper/restic_wrapper -b example-job -a backup-full -m
```If your system has an [MTA](https://cronitor.io/cron-reference/no-mta-installed-discarding-output) installed you will also get email if restic_wrapper itself fails for some reason but because most users do not have a properly configured MTA I chose to integrate basic notification functionality in restic_wrapper. Another advantage of letting restic_wrapper handle the notifications is that it can send different mails for failed and succeeded jobs without needing a lot of bash magic (which not everyone might be comfortable with).
## Changelog
- **v0.3.0**:
- Keep configs in separate dir
- provide example configs (also for rclone)
- make `restic_notify` compatible with newer versions of `s-nail`
- **v0.2.1**: Miscellaneous documentation updates.
- **v0.2.0**: Externalize notification functionality to make the script a lot simpler (and refactored a bunch).
- **v0.1.0**: Added `export-config` option to create a tarball of all your config files.