Go to file
Einar Forselv f97986c0af Include env vars in backup_runner 2019-04-18 03:52:28 +02:00
restic_volume_backup Include env vars in backup_runner 2019-04-18 03:52:28 +02:00
tests Include a sample of container json data 2019-04-18 03:50:53 +02:00
.dockerignore Update .dockerignore 2019-04-15 16:59:38 +02:00
.gitignore Ignore build files 2019-04-15 17:03:33 +02:00
Dockerfile Build new package 2019-04-15 16:24:57 +02:00
README.md Spelling error 2019-04-17 20:13:23 +02:00
crontab Major repo reorganizaion 2019-04-15 16:16:06 +02:00
docker-compose.yaml Add test service with volumes and include label 2019-04-17 00:09:13 +02:00
entrypoint.sh Major repo reorganizaion 2019-04-15 16:16:06 +02:00
pytest.ini Basic testcase setup 2019-04-15 19:07:14 +02:00
restic_volume_backup.env Basic env file 2019-04-15 17:03:47 +02:00
setup.py Upgrade to recent docker client 2019-04-17 03:45:51 +02:00
test.sh Working container spawner 2019-04-17 04:38:15 +02:00

README.md

restic-volume-backup

WORK IN PROGRESS

Backup using https://restic.net/ for a docker-compose setup.

Automatically detects and backs up volumes in a docker-compose setup. This includes both host mapped volumes and actual docker volumes.

  • Cron triggers backup
  • Volumes for all running containers are backed up

Configuration

Required env variables for restic:

RESTIC_REPOSITORY
RESTIC_PASSWORD

Backend specific env vars : https://restic.readthedocs.io/en/stable/040_backup.html#environment-variables

Example compose setup:

version: '3'
services:
  backup:
    build: restic-volume-backup
    environment:
      - RESTIC_REPOSITORY=<whatever restic supports>
      - RESTIC_PASSWORD=hopefullyasecturepw
    env_file:
      - some_other_vars.env
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
  example:
    image: some_image
    # Enable volume backup with label
    labels:
      restic-volume-backup.enabled: true
    # These volumes will be backed up
    volumes:
      # Docker volume
      - media:/srv/media
      # Host map
      - /srv/files:/srv/files

volumes:
  media:

Include

  example:
    image: some_image
    labels:
      restic-volume-backup.enabled: true
      restic-volume-backup.include: "files,data"
    volumes:
      # Source don't match include filter. No backup.
      - media:/srv/media
      # Matches include filter
      - files:/srv/files
      - /srv/data:/srv/data

volumes:
  media:
  files:

Exclude:

  example:
    image: some_image
    labels:
      restic-volume-backup.enabled: true
      restic-volume-backup.exclude: "media"
    volumes:
      # Excluded by filter
      - media:/srv/media
      # Backed up
      - files:/srv/files
      - /srv/data:/srv/data

volumes:
  media:
  files:

Running Tests

python setup.py develop
pip install -r tests/requirements.txt
pytest tests

TEMP

mysql://user:pw@host:port/dbname
postgresql://user:pw@host:port/dbname