mysql-s3-backup

Create MySQL database dumps and upload them to S3 with a tiny, multi-arch Docker image. Automate periodic backups easily with Kubernetes CronJobs.

This is a Docker multi-arch image designed for a single, crucial task: backing up your databases. It combines a minimal MySQL client with the powerful s3cmd S3 client, all within a lightweight Alpine Linux container. This setup allows you to create database dumps and transfer them directly to any S3-compatible object storage system.

The image is built for flexibility and efficiency. Its multi-arch support ensures it runs on most architectures, including amd64 and various ARM platforms. Because it uses a shell entry point, you can easily combine mysqldump and s3cmd commands to create custom backup scripts tailored to your specific needs.

Key features include:

  • Broad Compatibility: Works with any MySQL-compatible database (like MariaDB or Amazon Aurora) and any S3-compatible object storage.
  • Lightweight & Secure: Built on the latest Alpine Linux for a minimal footprint and up-to-date security.
  • Version Control: Offers latest tags for the newest updates and stable tags for environments requiring fixed, unchanging client versions.
  • Automation Ready: Perfectly suited for automated, periodic backups using tools like Kubernetes CronJobs, with a sample YAML file provided.
  • Encryption Support: Leverage s3cmd capabilities for encryption during transfer (SSL) and at rest (server-side or client-side with GPG).

Directory Structure

mysql-s3-backup
.env
docker-compose.yml

docker-compose.yml

services:
  mysql-s3-backup:
    image: angatar/mysql-s3-backup:latest
    container_name: mysql-s3-backup
    restart: unless-stopped
    environment:
      - MYSQL_HOST=mysql
      - MYSQL_PORT=3306
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=my_database
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
      - S3_BUCKET=my-backup-bucket
      - S3_REGION=us-east-1
      - S3_ENDPOINT=https://s3.amazonaws.com
      - S3_PREFIX=backups/mysql/
      - CRON_SCHEDULE=0 2 * * *

.env

MYSQL_USER=root
MYSQL_PASSWORD=your_super_secret_mysql_password
AWS_ACCESS_KEY_ID=your_s3_access_key_id
AWS_SECRET_ACCESS_KEY=your_s3_secret_access_key
Categories:

Share:

Ad
Favicon

 

  
 

Similar to mysql-s3-backup

Favicon

 

  
  
Favicon

 

  
  
Favicon