dineridthe/mysql-backup-s3
Docker container for Mysql backup to s3 compatible storage
88
This Docker image is designed to back up MySQL databases to an S3-compatible storage. Each database is saved as a separate .sql.gz
file in the specified S3 bucket and path, with the folder name based on the date and time of the backup.
.sql.gz
file.The following environment variables can be set to configure the backup process:
MYSQL_USER
- MySQL user.MYSQL_PASSWORD
- MySQL password.MYSQL_HOST
- MySQL host.MYSQL_PORT
- MySQL port (default: 3306).S3_BUCKET
- S3 bucket name.S3_ENDPOINT
- S3-compatible endpoint URL.S3_PATH
- Path within the S3 bucket to store backups (default: backup/
).AWS_ACCESS_KEY_ID
- AWS access key ID.AWS_SECRET_ACCESS_KEY
- AWS secret access key.AWS_REGION
- AWS region.Here is an example docker-compose.yml
to use this image:
version: '3.8'
services:
mysql:
image: mysql:8.0
container_name: mysql_container
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: testdb
MYSQL_USER: your_mysql_user
MYSQL_PASSWORD: your_mysql_password
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
backup:
build:
context: .
dockerfile: Dockerfile
container_name: backup_container
depends_on:
- mysql
environment:
MYSQL_USER: your_mysql_user
MYSQL_PASSWORD: your_mysql_password
MYSQL_HOST: mysql
MYSQL_PORT: 3306
S3_BUCKET: your_s3_bucket_name
S3_ENDPOINT: your_s3_endpoint
S3_PATH: backup/
AWS_ACCESS_KEY_ID: your_aws_access_key_id
AWS_SECRET_ACCESS_KEY: your_aws_secret_access_key
AWS_REGION: your_aws_region
volumes:
mysql_data:
docker pull dineridthe/mysql-backup-s3