This Docker image provides a straightforward way to automate periodic backups of your MySQL or MariaDB databases. It runs mysqldump on a schedule you define, ensuring your data is consistently protected without manual intervention. The container is highly configurable through environment variables, allowing you to tailor the backup process to your specific needs.
Key features include:
CRON_TIME format.MAX_BACKUPS limit to automatically remove old backups and manage disk space.INIT_BACKUP or when it stops with EXIT_BACKUP. You can also automatically restore the latest backup on startup.mysqldump using MYSQLDUMP_OPTS, adjust gzip compression levels, or even use plain SQL files.Simply link it to your database container, mount a volume for the backups, and let it handle the rest. It's an ideal companion for any project using MySQL or MariaDB within a Docker ecosystem.
services:
mysql:
image: mysql:8.0
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- ./mysql-data:/var/lib/mysql
backup:
image: fradelg/mysql-cron-backup
restart: always
depends_on:
- mysql
environment:
MYSQL_HOST: mysql
MYSQL_USER: root
MYSQL_PASS: ${MYSQL_ROOT_PASSWORD}
MAX_BACKUPS: 15
INIT_BACKUP: 1
CRON_TIME: "0 0 * * *"
volumes:
- ./backups:/backupMYSQL_ROOT_PASSWORD=your_super_secret_passwordAuto-fetched 12 minutes ago
Auto-fetched 12 minutes ago