Skip to content

Commit

Permalink
Add documentation and example configs
Browse files Browse the repository at this point in the history
  • Loading branch information
djmaze committed Nov 3, 2017
1 parent 6d9cfd3 commit 2cfb965
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
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!
17 changes: 17 additions & 0 deletions docker-compose.example.yml
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
19 changes: 19 additions & 0 deletions docker-swarm.example.yml
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

0 comments on commit 2cfb965

Please sign in to comment.