If you are deploying your applications using docker you may have wondered how to manage the backup of production databases. Indeed, traditionally, without docker, you would have made a small script based on mysql_dump in a cron on the host machine. Simple and efficient.
Unfortunately, under Docker, it is recommended not to install anything outside of the containers. So no cron or mysql_dump.
To address this challenge, KiwiBackup developed a method that allows you to back up a MySQL or MariaDB container directly from a dedicated backup container, without relying on the host server.
The concept is simple: deploy a backup container that includes all the necessary tools (cron, mysqldump, rotation scripts) to automate database backups in Docker environments.
This approach helps you:
- simplify deployments,
- secure backups,
- centralize backup tasks,
- remain compatible with Docker Swarm architectures and distributed infrastructures.
Simply add the backup image to your docker-compose file and provide the required information:
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: XXX
volumes:
- /data/volumes/mysql-db:/var/lib/mysql
backup:
image: kiwibackup/mysqlbackup
environment:
- DBHOST=db
- DBPASS=XXX
- DBLOGIN=root
- CRONH=1
- CRONM=19
volumes:
- /data/backup/db:/backup
- MySQL/MariaDB credentials,
- backup schedules,
- storage locations,
- dump retention policies.
Backup: A Key Pillar of Cyber Resilience
A Docker infrastructure without a proper backup policy remains vulnerable to human error, system failures, and cyberattacks.Protecting MySQL and MariaDB databases must now be considered an essential part of any business continuity and cyber resilience strategy.