db-backup

Backup multiple database types on a scheduled basis with many customizable options.

Directory Structure

    • .env
    • docker-compose.yml

docker-compose.yml

version: '3.9'
 
services:
  example-db:
    hostname: example-db-host
    container_name: example-db
    image: tiredofit/mariadb:10.11
    ports:
      - 3306:3306
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - ROOT_PASS=examplerootpassword
      - DB_NAME=example
      - DB_USER=example
      - DB_PASS=examplepassword
    restart: always
    networks:
      - example-db-network
 
  example-db-backup:
    container_name: example-db-backup
    image: tiredofit/db-backup
    volumes:
      - ./backups:/backup
      #- ./post-script.sh:/assets/custom-scripts/post-script.sh
    environment:
      - TIMEZONE=America/Vancouver
      - CONTAINER_NAME=example-db-backup
      - CONTAINER_ENABLE_MONITORING=FALSE
      # - DEBUG_MODE=TRUE
 
      - BACKUP_JOB_CONCURRENCY=1     # Only run one job at a time
      - DEFAULT_CHECKSUM=NONE        # Don't create checksums
      - DEFAULT_COMPRESSION=ZSTD     # Compress all with ZSTD
      - DEFAULT_BACKUP_INTERVAL=1440   # Backup every 1440 minutes
      - DEFAULT_BACKUP_BEGIN=0000      # Start backing up at midnight
      - DEFAULT_CLEANUP_TIME=8640    # Cleanup backups after a week
 
      - DB01_TYPE=mariadb
      - DB01_HOST=example-db-host
      - DB01_NAME=example
      - DB01_USER=example
      - DB01_PASS=examplepassword
      - DB01_BACKUP_INTERVAL=30        # (override) Backup every 30 minutes
      - DB01_BACKUP_BEGIN=+1           # (override) Backup starts immediately
      - DB01_CLEANUP_TIME=180        # (override) Cleanup backups they are older than 180 minutes
      - DB01_CHECKSUM=SHA1           # (override) Create a SHA1 checksum
      - DB01_COMPRESSION=GZ          # (override) Compress with GZIP
 
      #- DB02_TYPE=postgres
      #- DB02_HOST=example-postgres-host
      #- DB02_NAME=example
      #- DB02_USER=example
      #- DB02_PASS=examplepassword
      #- DB02_BACKUP_INTERVAL=60         # (override) Backup every 60 minutes
      #- DB02_BACKUP_BEGIN=+10           # (override) Backup starts in ten minutes
      #- DB02_CLEANUP_TIME=240         # (override) Cleanup backups they are older than 240 minutes
      #- DB02_CHECKSUM=MD5             # (override) Create a SHA1 checksum
      #- DB02_COMPRESSION=BZ           # (override) Compress with BZIP
 
    restart: always
    networks:
      - example-db-network
 
networks:
  example-db-network:
    name: example-db-network

Resources

Website:

GitHub: https://github.com/tiredofit/docker-db-backup

Docker Hub: https://hub.docker.com/r/tiredofit/db-backup

Configuration: https://github.com/tiredofit/docker-db-backup#configuration