Sign inSign up

resulgg/label-backup

By resulgg

โ€ขUpdated 11 months ago

Image
Developer tools
0

706

resulgg/label-backup repository overview

โ Label Backup

A Docker-aware backup agent that automatically discovers and backs up your containerized databases based on Docker labels.

โ ๐Ÿš€ Quick Start

# 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

โ โœจ Features

  • Zero Configuration: Just add labels to your database containers
  • Multi-Database Support: PostgreSQL, MySQL, MongoDB, Redis
  • Flexible Storage: Local filesystem or S3-compatible services
  • Docker Native: Monitors container events and adapts automatically
  • Health Monitoring: Built-in health checks and status endpoints
  • Webhook Notifications: Get notified of backup success/failure
  • Retention Policies: Automatic cleanup of old backups
  • Circuit Breaker: Prevents cascading failures
  • Real Checksums: SHA256 verification for backup integrity

โ ๐Ÿ“‹ Supported Databases

DatabaseBackup ToolConnection Format
PostgreSQLpg_dumppostgresql://user:pass@host:5432/db
MySQLmariadb-dumpmysql://user:pass@host:3306/db
MongoDBmongodumpmongodb://user:pass@host:27017/db
Redisredis-cliredis://:pass@host:6379/0

โ ๐Ÿท๏ธ Docker Labels

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"

โ ๐Ÿ”ง Configuration

โ Environment Variables
VariableDescriptionDefault
LOG_LEVELLogging level (debug, info, warn, error)info
LOCAL_BACKUP_PATHBase path for local backups/backups
GLOBAL_RETENTION_PERIODDefault retention period7d
CONCURRENT_BACKUP_LIMITMax concurrent backups20
BACKUP_TIMEOUT_MINUTESBackup timeout in minutes30
โ S3 Configuration
VariableDescription
BUCKET_NAMES3 bucket name
REGIONAWS region
ENDPOINTCustom S3 endpoint (MinIO, R2, etc.)
ACCESS_KEY_IDS3 access key
SECRET_ACCESS_KEYS3 secret key

โ ๐Ÿ“Š Health Endpoints

  • GET /healthz - Basic health check
  • GET /readyz - Readiness probe
  • GET /status - Detailed status with active jobs
  • GET /metadata?object=<backup-name> - Query backup metadata

โ ๐Ÿ“ Example Docker Compose

version: "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"

โ ๐Ÿงช Testing

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

โ ๐Ÿ“„ License

MIT License - see LICENSEโ  file for details.

โ ๐Ÿค Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.


Tag summary

Content type

Image

Digest

sha256:d48b1a266โ€ฆ

Size

63.5 MB

Last updated

11 months ago

docker pull resulgg/label-backup