Service to backup and/or restore mysql databases to/from S3
- Create an S3 bucket to hold your backups
- Turn versioning on for that bucket
- Supply all appropriate environment variables
- Run a backup and check your bucket for that backup
MODE
Valid values: backup
, restore
DB_NAMES
list of the database names
MYSQL_USER
user that accesses the database
MYSQL_PASSWORD
password for the MYSQL_USER
MYSQL_DUMP_ARGS
(optional) additional arguments to the mysqldump command, e.g., --max_allowed_packet=50M
AWS_ACCESS_KEY
used for S3 interactions
AWS_SECRET_KEY
used for S3 interactions
S3_BUCKET
e.g., s3://database-backups NOTE: no trailing slash
It's recommended that your S3 bucket have versioning turned on.
This image is built automatically on Docker Hub as silintl/mysql-backup-restore.
You'll need Docker, Docker Compose, and Make.
- cd .../mysql-backup-restore
- Upload test/world.sql.gz to the S3 bucket.
make db
# creates the MySQL DB servermake restore
# restores the DB dump filedocker ps -a
# get the Container ID of the exited restore containerdocker logs <containerID>
# review the restoration log messagesmake backup
# create a new DB dump filedocker ps -a
# get the Container ID of the exited backup containerdocker logs <containerID>
# review the backup log messagesmake restore
# restore the DB dump file from the new backupdocker ps -a
# get the Container ID of the exited restore containerdocker logs <containerID>
# review the restoration log messagesmake clean
# remove containers and networkdocker volume ls
# find the volume ID of the MySQL data containerdocker volume rm <volumeID>
# remove the data volumedocker images
# list existing imagesdocker image rm <imageID ...>
# remove images no longer needed