This docker container allows you to define a cron schedule to backup your files using restic.
The current status of backup (date of last run) is (pretty) printed when executing docker exec <container-name> status
(e.g. as part of the .bashrc
script).
The backup status is stored as Influx Line Protocol in /restic/status.info
and can be used to monitor the backup status. Find possible values in the (status.sh
)[https://github.com/steilerDev/restic-docker/blob/main/rootfs/restic/status.sh] script.
When running the docker, setting the hostname is recommended (see example below).
This only lists the most important and docker specific environmental variables. Restic specific variables can be found in the restic documentation.
CRON_SCHEDULE
The cron schedule for performing the backupRESTIC_REPOSITORY
The location of the repositoryRESTIC_PASSWORD
The password for the restic repositoryKEEP_LAST
Never delete the n last (most recent) snapshotsKEEP_HOURLY
For the last n hours in which a snapshot was made, keep only the last snapshot for each hourKEEP_DAILY
For the last n days which have one or more snapshots, only keep the last one for that dayKEEP_WEEKLY
For the last n weeks which have one or more snapshots, only keep the last one for that weekKEEP_MONTHLY
For the last n months which have one or more snapshots, only keep the last one for that monthKEEP_YEARLY
. For the last n years which have one or more snapshots, only keep the last one for that yearKEEP_TAG
Keep all snapshots which have all tags specified by this option (can be specified multiple times)KEEP_WITHIN
Keep all snapshots which have been made within theduration
of the latest snapshot.duration
needs to be a number of years, months, days, and hours, e.g.2y5m7d3h
will keep all snapshots made in the two years, five months, seven days, and three hours before the latest snapshotTZ
Timezone of installation for precise backup execution (Defaults toEurope/Berlin
)
The following paths are recommended for persisting state and/or accessing configurations
/backup/
The source of the backup/restored/
(recommended)
The destination for restoring files/restic/status.info
(optional)
Read the current backup status from this file/pre-run.d
(optional) This tool will userun-parts
to execute the content of this dir before a backup (if it exists)
Usage with nginx-proxy
inside of predefined steilerGroup
network.
version: '2'
services:
<service-name>:
image: steilerdev/restic:latest
container_name: backup
restart: unless-stopped
hostname: "<hostname>"
environment:
CRON_SCHEDULE: "0 4 * * 0,3"
RESTIC_REPOSITORY: "b2:<bucket-name>:<folder-name>/"
RESTIC_PASSWORD: "<pwd>"
RESTIC_COMPRESSION: "max"
B2_ACCOUNT_ID: "<account-id>"
B2_ACCOUNT_KEY: "<account-key"
KEEP_DAILY: "7"
KEEP_WEEKLY: "5"
KEEP_MONTHLY: "12"
KEEP_YEARLY: "5"
volumes:
- /opt:/backup/opt:ro
- /root:/backup/root:ro
- /home:/backup/home:ro
- /media/files/_restored:/restored
- /opt/docker/backup/volumes/status.info:/restic/status.info
networks:
default:
name: steilerGroup
external: true