A Docker-aware backup agent that automatically discovers and backs up your containerized databases based on Docker labels.
# Pull the image
docker pull resulgg/label-backup:latest
# Run with Docker Compose
docker run -d \
--name label-backup \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v ./backups:/backups \
-e LOCAL_BACKUP_PATH=/backups \
-e LOG_LEVEL=info \
-p 8080:8080 \
resulgg/label-backup:latest
| Database | Backup Tool | Connection Format |
|---|---|---|
| PostgreSQL | pg_dump | postgresql://user:pass@host:5432/db |
| MySQL | mariadb-dump | mysql://user:pass@host:3306/db |
| MongoDB | mongodump | mongodb://user:pass@host:27017/db |
| Redis | redis-cli | redis://:pass@host:6379/0 |
Add these labels to your database containers:
labels:
backup.enabled: "true"
backup.type: "postgres"
backup.cron: "0 2 * * *" # Daily at 2 AM
backup.conn: "postgresql://user:pass@postgres:5432/mydb"
backup.dest: "local"
backup.prefix: "postgres-backups"
backup.retention: "7d"
| Variable | Description | Default |
|---|---|---|
LOG_LEVEL | Logging level (debug, info, warn, error) | info |
LOCAL_BACKUP_PATH | Base path for local backups | /backups |
GLOBAL_RETENTION_PERIOD | Default retention period | 7d |
CONCURRENT_BACKUP_LIMIT | Max concurrent backups | 20 |
BACKUP_TIMEOUT_MINUTES | Backup timeout in minutes | 30 |
| Variable | Description |
|---|---|
BUCKET_NAME | S3 bucket name |
REGION | AWS region |
ENDPOINT | Custom S3 endpoint (MinIO, R2, etc.) |
ACCESS_KEY_ID | S3 access key |
SECRET_ACCESS_KEY | S3 secret key |
GET /healthz - Basic health checkGET /readyz - Readiness probeGET /status - Detailed status with active jobsGET /metadata?object=<backup-name> - Query backup metadataversion: "3.8"
services:
postgres:
image: postgres:15
environment:
POSTGRES_DB: myapp
POSTGRES_USER: appuser
POSTGRES_PASSWORD: apppass
labels:
backup.enabled: "true"
backup.cron: "0 2 * * *"
backup.type: "postgres"
backup.conn: "postgresql://appuser:apppass@postgres:5432/myapp"
backup.dest: "local"
backup.prefix: "postgres-backups"
backup.retention: "7d"
label-backup:
image: resulgg/label-backup:latest
environment:
LOCAL_BACKUP_PATH: "/backups"
GLOBAL_RETENTION_PERIOD: "30d"
LOG_LEVEL: "info"
volumes:
- ./backups:/backups
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- postgres
ports:
- "8080:8080"
Comprehensive test suite available:
# Clone repository
git clone https://github.com/resulgg/label-backup.git
cd label-backup
# Run integration tests
docker-compose -f integration-tests/docker-compose-test.yml up --build -d
./integration-tests/test.sh
MIT License - see LICENSEโ file for details.
Contributions are welcome! Please feel free to open an issue or submit a pull request.
Content type
Image
Digest
sha256:d48b1a266โฆ
Size
63.5 MB
Last updated
11 months ago
docker pull resulgg/label-backup