This docker image backup and encrypt MySQL databases to S3/Minio periodically.
docker run -d --restart unless-stopped \
--name mysql_backup \
-e AWS_ACCESS_KEY_ID="your-access-key" \
-e AWS_SECRET_ACCESS_KEY="your-secret-access-keys" \
-e PGP_KEY=YOUR_PGP_PUBLIC_KEY \
-e BACKUP_SCHEDULE="0 * * * *" \
-e MYSQL_DATABASE=your-dbname \
-e MYSQL_HOST=your-mysql-container \
-e MYSQL_USER=your-mysql-username \
-e MYSQL_PASSWORD="your-mysql-password" \
--network your-network \
chaifeng/mysql-backup-s3-gpg
docker run -d --restart unless-stopped \
--name mysql_backup \
-e AWS_ENDPOINT="https://your.minio.server.example.com" \
-e AWS_ACCESS_KEY_ID="your-access-key" \
-e AWS_SECRET_ACCESS_KEY="your-secret-access-keys" \
-e PGP_KEY=YOUR_PGP_PUBLIC_KEY \
-e BACKUP_SCHEDULE="0 * * * *" \
-e MYSQL_DATABASE=your-dbname \
-e MYSQL_HOST=your-mysql-container \
-e MYSQL_USER=root \
-e MYSQL_PASSWORD="your-mysql-password" \
--network your-network \
chaifeng/mysql-backup-s3-gpg
docker run -d --restart unless-stopped \
--name mysql_backup \
-e AWS_ENDPOINT="https://your.minio.server.example.com" \
-e AWS_ACCESS_KEY_ID="your-access-key" \
-e AWS_SECRET_ACCESS_KEY="your-secret-access-keys" \
-v /path/to/your/pgp-public-key.txt:/pgp.txt \
-e PGP_KEY=/pgp.txt \
-e BACKUP_SCHEDULE="0 * * * *" \
-e MYSQL_DATABASE=your-dbname \
-e MYSQL_HOST=your-mysql-container \
-e MYSQL_USER=root \
-e MYSQL_PASSWORD="your-mysql-password" \
--network your-network \
chaifeng/mysql-backup-s3-gpg
docker run -d --restart unless-stopped \
--name mysql_backup \
-e AWS_ACCESS_KEY_ID="your-access-key" \
-e AWS_SECRET_ACCESS_KEY="your-secret-access-keys" \
-e PGP_KEY=https://example.com/pgp-key.txt \
-e BACKUP_SCHEDULE="0 * * * *" \
-e MYSQL_DATABASE=your-dbname \
-e MYSQL_HOST=your-mysql-container \
-e MYSQL_USER=your-mysql-username \
-e MYSQL_PASSWORD="your-mysql-password" \
--network your-network \
chaifeng/mysql-backup-s3-gpg
AWS_ACCESS_KEY_ID
Access KeyAWS_SECRET_ACCESS_KEY
Securet Access KeyPGP_KEY
Your PGP public key ID, used to encrypt your backups Can be a PGP key ID or a local filename or a http/https/ftp URL.MYSQL_HOST
the host/ip of your mysql databaseMYSQL_USER
the username of your mysql databaseMYSQL_PASSWORD
the password of your mysql databaseMYSQL_ROOT_PASSWORD
the root's password of your mysql database
AWS_DEFAULT_REGION
us-east-1
by defaultAWS_ENDPOINT
Customize this variable if you are using Minio, the url of your Minio serverPGP_KEYSERVER
the PGP key server used to retrieve you PGP public key, supports multiple servers seperated by commaBACKUP_SCHEDULE
the interval of cron job to run mysqldump.0 0 * * *
by defaultBACKUP_BUCKET
the bucket of your S3/MinioBACKUP_PREFIX
the default value ismysql/%Y/%m/%d/mysql-
, please see the strftime(3) manual pageBACKUP_SUFFIX
the default value is-%Y%m%d-%H%M.sql.gz.gpg
, please see the strftime(3) manual pageMYSQL_DATABASE
the database name to dump. Default is to backup all databases
gpg --decrypt your-backup.gpg
aws s3 cp s3://your-bucket/path/to/your/backup.gpg - | gpg --output backup.sql --decrypt
mc cat minio/your-bucket/path/to/your/backup.gpg | gpg --output backup.sql --decrypt