Docs / Backup & Recovery / How to Back Up Docker Volumes Properly

How to Back Up Docker Volumes Properly

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 29 views · 2 min read

Why Back Up Docker Volumes?

Docker containers are ephemeral, but the data stored in volumes is not. Databases, uploaded files, and configuration data in Docker volumes must be backed up regularly to prevent data loss on your Breeze.

Identify Your Volumes

docker volume ls
docker inspect <volume_name> | grep Mountpoint

Method 1: Backup with a Temporary Container

Use a temporary container to tar the volume contents:

docker run --rm \
  -v my_volume:/data \
  -v /backup:/backup \
  alpine tar czf /backup/my_volume_$(date +%Y%m%d).tar.gz -C /data .

This mounts the target volume and a backup directory, then creates a compressed archive.

Method 2: Database-Specific Dumps

For databases, use native dump tools for consistent backups:

# MySQL/MariaDB
docker exec my_mysql mysqldump -u root -pYourPass --all-databases > /backup/mysql_$(date +%Y%m%d).sql

# PostgreSQL
docker exec my_postgres pg_dumpall -U postgres > /backup/postgres_$(date +%Y%m%d).sql

Method 3: Docker Volume Backup Plugin

Use docker-volume-backup as a sidecar container for automated scheduling:

docker run -d \
  --name backup \
  -v my_volume:/backup/data:ro \
  -v /backup:/archive \
  -e BACKUP_CRON_EXPRESSION="0 3 * * *" \
  offen/docker-volume-backup:latest

Automate with a Cron Script

Create a script that iterates over all named volumes:

#!/bin/bash
BACKUP_DIR=/backup/docker-volumes
mkdir -p "$BACKUP_DIR"
for VOL in $(docker volume ls -q); do
  docker run --rm -v "$VOL":/data -v "$BACKUP_DIR":/backup alpine \
    tar czf "/backup/${VOL}_$(date +%Y%m%d).tar.gz" -C /data .
done
find "$BACKUP_DIR" -mtime +30 -delete

Schedule this script to run nightly via cron for hands-off volume protection.

Was this article helpful?