Backup Docker volumes locally or to any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage
Find a file
dependabot[bot] dd8ff5ee0c
Build using Go 1.22 (#356)
* Bump golang from 1.21-alpine to 1.22-alpine

Bumps golang from 1.21-alpine to 1.22-alpine.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update go version in mod file and lint action

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Frederik Ring <frederik.ring@gmail.com>
2024-02-16 20:52:45 +01:00
.github Build using Go 1.22 (#356) 2024-02-16 20:52:45 +01:00
cmd/backup Auto prepend caller when wrapping errors 2024-02-16 20:19:58 +01:00
docs Move cron scheduling inside application (#338) 2024-02-12 16:04:12 +01:00
internal Auto prepend caller when wrapping errors 2024-02-16 20:19:58 +01:00
test Conf files should expand env vars (#363) 2024-02-15 12:04:44 +01:00
.dockerignore Fix WebDAV spelling, remove some inconsistencies (#143) 2022-08-18 12:37:45 +02:00
.editorconfig improve logging messages 2021-08-23 14:48:33 +02:00
.golangci.yml Cleanup: Lint warnings and deprecated packages (#263) 2023-08-27 18:14:55 +02:00
Dockerfile Build using Go 1.22 (#356) 2024-02-16 20:52:45 +01:00
go.mod Build using Go 1.22 (#356) 2024-02-16 20:52:45 +01:00
go.sum Bump github.com/docker/cli (#353) 2024-02-13 09:44:32 +01:00
LICENSE Initial commit 2021-04-02 13:45:33 +02:00
README.md Docs site (#269) 2023-09-16 11:54:39 +02:00

Offen logo

docker-volume-backup

Backup Docker volumes locally or to any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage.

The offen/docker-volume-backup Docker image can be used as a lightweight (below 15MB) companion container to an existing Docker setup. It handles recurring or one-off backups of Docker volumes to a local directory, any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage (or any combination thereof) and rotates away old backups if configured. It also supports encrypting your backups using GPG and sending notifications for (failed) backup runs.

Documentation is found at https://offen.github.io/docker-volume-backup


Quickstart

Recurring backups in a compose setup

Add a backup service to your compose setup and mount the volumes you would like to see backed up:

version: '3'

services:
  volume-consumer:
    build:
      context: ./my-app
    volumes:
      - data:/var/my-app
    labels:
      # This means the container will be stopped during backup to ensure
      # backup integrity. You can omit this label if stopping during backup
      # not required.
      - docker-volume-backup.stop-during-backup=true

  backup:
    # In production, it is advised to lock your image tag to a proper
    # release version instead of using `latest`.
    # Check https://github.com/offen/docker-volume-backup/releases
    # for a list of available releases.
    image: offen/docker-volume-backup:latest
    restart: always
    env_file: ./backup.env # see below for configuration reference
    volumes:
      - data:/backup/my-app-backup:ro
      # Mounting the Docker socket allows the script to stop and restart
      # the container during backup. You can omit this if you don't want
      # to stop the container. In case you need to proxy the socket, you can
      # also provide a location by setting `DOCKER_HOST` in the container
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # If you mount a local directory or volume to `/archive` a local
      # copy of the backup will be stored there. You can override the
      # location inside of the container by setting `BACKUP_ARCHIVE`.
      # You can omit this if you do not want to keep local backups.
      - /path/to/local_backups:/archive
volumes:
  data:

One-off backups using Docker CLI

To run a one time backup, mount the volume you would like to see backed up into a container and run the backup command:

docker run --rm \
  -v data:/backup/data \
  --env AWS_ACCESS_KEY_ID="<xxx>" \
  --env AWS_SECRET_ACCESS_KEY="<xxx>" \
  --env AWS_S3_BUCKET_NAME="<xxx>" \
  --entrypoint backup \
  offen/docker-volume-backup:v2

Alternatively, pass a --env-file in order to use a full config as described below.