No description
  • Shell 95.4%
  • Dockerfile 4.6%
Find a file
Gokhan Sari e040924773
All checks were successful
Release / Release (push) Successful in 17s
Enable backing up multiple databases (#4)
Reviewed-on: #4
2026-02-23 01:23:22 +00:00
.forgejo/workflows Migrate from woodpecker-ci to forgejo actions (#2) 2025-12-24 16:34:33 +00:00
.idea Add SFTP destination option (#1) 2025-08-25 15:23:18 +00:00
Dockerfile Enable backing up multiple databases (#4) 2026-02-23 01:23:22 +00:00
entrypoint.sh Enable backing up multiple databases (#4) 2026-02-23 01:23:22 +00:00
LICENSE First commit 2024-12-09 00:39:41 +03:00
README.md Enable backing up multiple databases (#4) 2026-02-23 01:23:22 +00:00

mysql-backup is a MySQL backup helper that:

  • Takes the dump of one or more MySQL databases
  • Uploads it to either AWS S3 or SFTP destination
  • Reports to WebGazer (optional)

Usage

Environment variables

Required variables

Variable Required Description
DESTINATION_KIND Destination type: s3 or sftp
MYSQL_DATABASES Space-separated MySQL database name(s)
MYSQL_PASSWORD MySQL server password

MySQL configuration

Variable Required Default value Description
MYSQL_HOST mysql MySQL server host
MYSQL_PORT 3306 MySQL server port
MYSQL_USER root MySQL server user

S3 destination (when DESTINATION_KIND=s3)

Variable Required Default value Description
S3_ACCESS_KEY_ID Access key id for the AWS account
S3_REGION Region for the AWS bucket
S3_SECRET_ACCESS_KEY Secret access key for the AWS account
DESTINATION_PATH S3 bucket and path (e.g. "my-bucket/mysql-backup")
S3_PROVIDER AWS S3 provider (AWS, MinIO, etc.)
S3_STORAGE_CLASS STANDARD_IA AWS S3 storage class (see https://aws.amazon.com/s3/storage-classes/ and https://rclone.org/s3/#s3-storage-class for options)

SFTP destination (when DESTINATION_KIND=sftp)

Variable Required Default value Description
SFTP_HOST SFTP server hostname
SFTP_USER SFTP username
DESTINATION_PATH SFTP destination path
SFTP_PORT 22 SFTP server port
SFTP_PASSWORD SFTP password (either this or SFTP_PRIVATE_KEY must be set)
SFTP_PRIVATE_KEY Base64-encoded private key (either this or SFTP_PASSWORD must be set)

Optional variables

Variable Required Description
WEBGAZER_HEARTBEAT_URL WebGazer Heartbeat Monitor URL

Note: For SFTP authentication, you must provide either SFTP_PASSWORD or SFTP_PRIVATE_KEY, but not both.

Running

S3 Example

$ docker run \
  -e DESTINATION_KIND=s3 \
  -e S3_ACCESS_KEY_ID=<aws_access_key_id> \
  -e S3_REGION=<aws_region> \
  -e S3_SECRET_ACCESS_KEY=<aws_secret_access_key> \
  -e DESTINATION_PATH=<bucket/path> \
  -e S3_STORAGE_CLASS=<aws_s3_storage_class[STANDARD_IA]> \
  -e MYSQL_DATABASES="<database1 database2 ...>" \
  -e MYSQL_HOST=<mysql_hostname[mysql]> \
  -e MYSQL_PASSWORD=<mysql_password> \
  -e MYSQL_PORT=<mysql_port[3306]> \
  -e MYSQL_USER=<mysql_user[root]> \
  -e WEBGAZER_HEARTBEAT_URL=<webgazer_heartbeat_url> \
  th0th/mysql-backup

SFTP Example

$ docker run \
  -e DESTINATION_KIND=sftp \
  -e SFTP_HOST=<sftp_host> \
  -e SFTP_USER=<sftp_user> \
  -e SFTP_PASSWORD=<sftp_password> \
  -e DESTINATION_PATH=<sftp_path> \
  -e SFTP_PORT=<sftp_port[22]> \
  -e MYSQL_DATABASES="<database1 database2 ...>" \
  -e MYSQL_HOST=<mysql_hostname[mysql]> \
  -e MYSQL_PASSWORD=<mysql_password> \
  -e MYSQL_PORT=<mysql_port[3306]> \
  -e MYSQL_USER=<mysql_user[root]> \
  -e WEBGAZER_HEARTBEAT_URL=<webgazer_heartbeat_url> \
  th0th/mysql-backup

SFTP with Private Key Example

$ docker run \
  -e DESTINATION_KIND=sftp \
  -e SFTP_HOST=<sftp_host> \
  -e SFTP_USER=<sftp_user> \
  -e SFTP_PRIVATE_KEY=<base64_encoded_private_key> \
  -e DESTINATION_PATH=<sftp_path> \
  -e SFTP_PORT=<sftp_port[22]> \
  -e MYSQL_DATABASES="<database1 database2 ...>" \
  -e MYSQL_HOST=<mysql_hostname[mysql]> \
  -e MYSQL_PASSWORD=<mysql_password> \
  -e MYSQL_PORT=<mysql_port[3306]> \
  -e MYSQL_USER=<mysql_user[root]> \
  -e WEBGAZER_HEARTBEAT_URL=<webgazer_heartbeat_url> \
  th0th/mysql-backup

Examples

S3 Example

$ docker run \
  -e DESTINATION_KIND=s3 \
  -e S3_ACCESS_KEY_ID=g9XqNnqKmUk6xqwkStkN \
  -e S3_REGION=eu-west-1 \
  -e DESTINATION_PATH=my-bucket/mysql-backup \
  -e S3_STORAGE_CLASS=GLACIER \
  -e S3_SECRET_ACCESS_KEY=GLBZ8mQf27UL57YHbkLhXWtfJWVwtUBbQup6mFzw \
  -e MYSQL_DATABASES="database1 database2" \
  -e MYSQL_HOST=mysql \
  -e MYSQL_PASSWORD=mysql_password \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=mysql_user \
  -e WEBGAZER_HEARTBEAT_URL=https://heartbeat.webgazer.io/1-8f713c75d659 \
  th0th/mysql-backup

SFTP Example

$ docker run \
  -e DESTINATION_KIND=sftp \
  -e SFTP_HOST=sftp.example.com \
  -e SFTP_USER=backup_user \
  -e SFTP_PASSWORD=secure_password \
  -e DESTINATION_PATH=/backups/mysql \
  -e SFTP_PORT=22 \
  -e MYSQL_DATABASES="database1 database2" \
  -e MYSQL_HOST=mysql \
  -e MYSQL_PASSWORD=mysql_password \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=mysql_user \
  -e WEBGAZER_HEARTBEAT_URL=https://heartbeat.webgazer.io/1-8f713c75d659 \
  th0th/mysql-backup

Shameless plug

I am an indie hacker, and I am running two services that might be useful for your business. Check them out :)

WebGazer

WebGazer

WebGazer is a monitoring service that checks your website, cron jobs, or scheduled tasks on a regular basis. It notifies you with instant alerts in case of a problem. That way, you have peace of mind about the status of your service without manually checking it.

PoeticMetric

PoeticMetric

PoeticMetric is a privacy-first, regulation-compliant, blazingly fast analytics tool.

No cookies or personal data collection. So you don't have to worry about cookie banners or GDPR, CCPA, and PECR compliance.

License

Copyright © 2022, Gokhan Sari. Released under the MIT License.