** Backup Docker Volumes Without the Headache: Meet docker-volume-backup
Let’s be real. Backing up Docker volumes is one of those tasks that’s easy to put off. You can script it, but then you have to handle edge cases, rotation, errors, and storage targets. Or you can use a dedicated tool that just works.
Enter docker-volume-backup. It’s a tiny companion container (around 25MB) that sits next to your app containers and backs up their volumes to wherever you need. Local directory, S3, WebDAV, Dropbox, or SSH. No complex setup, no runtime dependencies beyond Docker. Just point and go.
What It Does
docker-volume-backup is a single-purpose Docker image. You run it as a sidecar container that mounts the volumes you want to back up and a destination. On schedule (or on demand), it:
- Creates a compressed archive of the volume data
- Optionally encrypts the backup
- Pushes it to local storage, S3, WebDAV, Dropbox, or SSH
- Prunes old backups according to your retention policy
- Notifies you on success or failure
That’s it. One container, one config file, and you get consistent, automated backups.
Why It’s Cool
This project gets a lot of small things right:
- Tiny footprint. 25MB means it won’t eat into your server resources. You can run it on a Raspberry Pi without worry.
- Multiple destinations out of the box. S3 is great, but sometimes you need WebDAV for a self-hosted Nextcloud or Dropbox for a team folder. SSH is perfect for older infrastructure. No plugins, no extra installs.
- Retention policies built in. Set
BACKUP_RETENTION_DAYSand it handles cleanup. No more cron jobs that fill your disk. - Works with Docker Compose and Swarm. You declare a second service in your compose file, and everything ties together neatly.
- No custom scripts. Unlike rolling your own backup with
tarandaws s3 cp, this container handles compression, encryption, and upload in a predictable way. Less debugging, more sleeping.
How to Try It
If you already have a Docker setup, add this to your docker-compose.yml as a companion service:
services:
backup:
image: offen/docker-volume-backup:v2
restart: always
volumes:
- my_app_data:/backup/my_app_data:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
BACKUP_FILENAME: my-app-%Y-%m-%dT%H-%M-%S.tar.gz
BACKUP_RETENTION_DAYS: 7
AWS_S3_BUCKET_NAME: my-backup-bucket
AWS_ACCESS_KEY_ID: your-key
AWS_SECRET_ACCESS_KEY: your-secret
Run docker compose up -d, and backups start happening on the default schedule (daily at 2 AM). You can also trigger a backup manually with:
docker exec <container_name> backup
Check the GitHub repo for details on WebDAV, Dropbox, or SSH targets. It’s all environment variables.
Final Thoughts
This tool won’t replace a full disaster recovery plan. But for day-to-day volume backups, it’s hard to beat. You get something that works across environments, stores data where you already keep things, and doesn’t need babysitting. It’s the kind of tool you set up once and forget about until the day you need it. And that’s exactly what you want from a backup solution.
If you’re running Docker volumes in production or even on a home server, give it a spin. It’s one less thing to worry about.
Found this on GitHub? Follow us at @githubprojects for more useful tools.