mysql-backup

Automate MySQL database backups and restores in containers. Schedule dumps, send to local or cloud storage, and prune old backups with a simple container image.

This tool provides a simple and powerful way to manage MySQL database backups and restores, specifically designed for containerized environments. It can be run as a lightweight container image or as a standalone binary, offering flexibility for various workflows. You can automate your entire backup process with extensive configuration options.

Key features include:

  • Scheduled Backups: Define exactly how often backups should run and at what time of day they should begin.
  • Flexible Storage Targets: Save your database dumps to a local file path, an SMB share, or an S3 bucket.
  • Automated Pruning: Keep your backup storage clean by automatically deleting backups older than a specified time or keeping only a certain number of recent backups.
  • Full Restore Capabilities: Easily restore a full database dump from any of your supported storage targets.
  • Selective Operations: Choose to back up or restore only specific databases from a multi-schema instance.
  • Easy Configuration: Manage all settings through environment variables or a straightforward YAML configuration file.

Directory Structure

mysql-backup
backups
mysql-data
.env
docker-compose.yml

docker-compose.yml

services:
  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: example_db
    volumes:
      - ./mysql-data:/var/lib/mysql

  backup:
    image: databacker/mysql-backup:latest
    restart: always
    depends_on:
      - db
    environment:
      DB_SERVER: db
      DB_USER: root
      DB_PASS: ${MYSQL_ROOT_PASSWORD}
      DB_NAMES: example_db
      CRON_TIME: "0 0 * * *"
      MAX_BACKUPS: 7
      INIT_BACKUP: "true"
    volumes:
      - ./backups:/db_backup

.env

MYSQL_ROOT_PASSWORD=your_super_secret_password
Categories:

Share:

Ad
Favicon

 

  
 

Similar to mysql-backup

Favicon

 

  
  
Favicon

 

  
  
Favicon