realestatepilot / docker-restic-backupclient

Easy backups with docker and restic
MIT License
5 stars 5 forks source link

Easy backups with docker and restic

Features

Removed features

Volumes

Command and Arguments

Scheduling example

/scripts/backup_client.py schedule --prune '0 23 00 * * SUN' '@daily'

This would schedule a backup every day at 00:00. On end of Sunday, a prune would be scheduled (if the previous backup is not runing anymore). If the prune takes more than 1 hour, the backup at Monday would be skipped.

Env vars

Env var substitution

Env vars may contain placeholders like $(OTHER_ENV_VAR) which will be resolved recusively up to 10 levels. If resolution is not possible, the placeholder would be kept.

Yaml configuration examples

---

# if set, old backups will be deleted according to the rules below.
# At least one of [last, daily, weekly, monthly, yearly] needs to be set to make this work
keep:
  last: 1
  daily: 7
  weekly: 4
  monthly: 3
  yearly: 1

# Caches are excluded by default. See http://bford.info/cachedir/spec.html on hot to mark a cache dir
exclude-caches: false

# Exclude some files from backup. See https://restic.readthedocs.io/en/latest/040_backup.html#including-and-excluding-files for details
exclude:
  - *.bak
  - .cache/*

# Include files 
# a file contains paths (with patterns) which to backup for
# if use include-from define ALL backup paths inside file. Also backup paths from database dumps!
include-from: 
  - /tmp/backupset.txt

# define restic cache-dir
# dir has to match with container environment if used
# cache-dir: /restic-cache

# smtp configuration to send mails when backup fails
smtp:
  host: smtp.host.com
  username: user@host.com
  password: guest
  from: user@host@com
  recipient: recipient@example.com

# Run some script(s) before backup
pre-backup-scripts:
  - description: Doing some pre-backup stuff
    script: |
      echo "x"
      exit 1
    fail-on-error: true

# File changed are by default done by mtime and size, inode changes are ignored.
# set ignore-inode to false to thread files as changed if the inode is changed
ignore-inode: false

# Perform a dump of elasticsearch
# * url is required
# * username and password for basic auth are optional
# * either include or exclude can be set to a list of regular expressions to include/exclude indices
elasticdump:
  url: https://es.local:9200/
  username: esuser
  password: s3cr3t
  exclude:
    - ^.kibana

# Perform a dump of mysql
# * host is required
# * port defaults to 3306
# * username and password are required
# * either include or exclude can be set to a list of regular expressions to include/exclude databases
mysqldump:
  host: database.local
  username: root
  password: s3cr3t
  exclude:
    - ^test
  mysqldump-extra-args:
    - --skip-lock-tables
    - --single-transaction

# Perform a dump of postgresql
# * host is required
# * port defaults to 5432
# * username and password are required
# * either include or exclude can be set to a list of regular expressions to include/exclude databases
pgdump:
  host: database.local
  username: root
  password: s3cr3t
  exclude:
    - ^test

# Perform a dump of mongodb
# * host is required
# * port defaults to 27017
# * username and password are required
# * dump_version defaults to 3. Choose between mongodump version 3.x.x and 4.x.x. Implemented to avoid failing dumps due to version mismatch.
mongodump:
  host: mongodb.local
  username: root
  password: s3cr3t
  dump_version: 4