-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation and example configs
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Resticker | ||
|
||
Run automatic [restic](https://restic.github.io/) backups via a Docker container. | ||
|
||
## Features | ||
|
||
* run scheduled backups | ||
* backup to any (local or remote) target supported by restic | ||
* add custom tags to backups | ||
* automatic forgetting of old backups | ||
* can be used as a (global) Docker swarm service in order to backup every cluster node | ||
* multi-arch: runs on `amd64` as well as `armv7` (for now) | ||
|
||
## Usage | ||
|
||
Use the supplied example configs to set up a backup schedule. | ||
|
||
### With Docker Compose | ||
|
||
Adjust the supplied [docker-compose.yml](docker-compose.example.yml) as needed. Then run: | ||
|
||
docker-compose up -d | ||
|
||
### With Docker Swarm mode | ||
|
||
Adjust the supplied [docker-swarm.yml](docker-swarm.example.yml) as needed. Then deploy it as a stack: | ||
|
||
docker stack deploy -f docker-swarm.yml backup | ||
|
||
### Advanced usage | ||
|
||
You can use the same config to run any restic command with the given configuration. | ||
|
||
When using the Docker Compose setup: | ||
|
||
docker-compose run --rm app <RESTIC ARGS> | ||
|
||
E.g. | ||
|
||
docker-compose run --rm app snapshots | ||
|
||
## Configuration options | ||
|
||
* `BACKUP_CRON` - A cron expression for when to run the backup. E.g. `0 30 3 * * *` in order to run every night at 3:30 am. See [the go-cron documentation](https://godoc.org/github.com/robfig/cron) for details on the expression format | ||
* `RESTIC_REPOSITORY` - location of the restic repository. You can use [any target supported by restic](https://restic.readthedocs.io/en/stable/manual.html#initialize-a-repository). Default `/mnt/restic` | ||
* `RESTIC_BACKUP_SOURCES` - source directory to backup. Make sure to mount this into the container as a volume (see the example configs). Default `/data` | ||
* `RESTIC_PASSWORD` - password for the restic repository. Will also be used to initialize the repository if it is not yet initialized | ||
* `RESTIC_BACKUP_TAGS` - Optional. Tags to set on each snapshot, separated by commas. E.g. `swarm,docker-volumes` | ||
* `RESTIC_FORGET_ARGS` - Optional. If specified `restic forget` is run with the given arguments after each backup. E.g. `--prune --keep-last 14 --keep-daily 1` | ||
* (Additional variables as needed for the chosen backup target. E.g. `B2_ACCOUNT_ID` and `B2_ACCOUNT_KEY` for Backblaze B2.) | ||
|
||
## Credits | ||
|
||
[restic-backup-docker](https://github.com/Lobaro/restic-backup-docker) was used as a starting point. Thanks! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "3.3" | ||
|
||
services: | ||
app: | ||
image: mazzolino/restic | ||
hostname: docker | ||
environment: | ||
BACKUP_CRON: "0 30 3 * * *" | ||
RESTIC_REPOSITORY: b2:my-repo:/restic | ||
RESTIC_PASSWORD: supersecret | ||
RESTIC_BACKUP_SOURCES: /mnt/volumes | ||
RESTIC_BACKUP_TAGS: docker-volumes | ||
RESTIC_FORGET_ARGS: --prune --keep-last 14 --keep-daily 1 | ||
B2_ACCOUNT_ID: xxxxxxx | ||
B2_ACCOUNT_KEY: yyyyyyyy | ||
volumes: | ||
- /var/lib/docker/volumes:/mnt/volumes:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
version: "3.3" | ||
|
||
services: | ||
app: | ||
image: mazzolino/restic | ||
environment: | ||
BACKUP_CRON: "0 30 3 * * *" | ||
RESTIC_REPOSITORY: b2:my-repo:/restic | ||
RESTIC_PASSWORD: supersecret | ||
RESTIC_BACKUP_SOURCES: /mnt/volumes | ||
RESTIC_BACKUP_TAGS: docker-volumes | ||
RESTIC_FORGET_ARGS: --prune --keep-last 14 --keep-daily 1 | ||
B2_ACCOUNT_ID: xxxxxxx | ||
B2_ACCOUNT_KEY: yyyyyyyy | ||
hostname: "{{.Node.ID}}" | ||
volumes: | ||
- /var/lib/docker/volumes:/mnt/volumes:ro | ||
deploy: | ||
mode: global |