Friday, May 14, 2021

docker-mysql-backup-restore-s3 Docker backup and restore using S3 AWS

docker-mysql-backup-restore-s3 is Docker app that can be used to backup and restore a MySQL using AWS S3 as storage.



I want to run a mysql backup and restore script on my devices that use S3 AWS as storage for the dump. The best way to do this in a multi-enviroment to me is to pack this script in to a Docker image.

You can find it on Docker Hub here: https://hub.docker.com/repository/docker/davidegironi/docker-mysql-backup-restore-s3

To perform a backup simply run the following docker command, selecting the right parameter for your AWS and MySQL server

docker run -e ACTION=backup -e S3_ACCESSKEYID=awskey -e S3_SECRETACCESSKEY=awssecret -e S3_BUCKET=s3bucket -e S3_PREFIX=backup -e S3_REGION=awsregion -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_HOST=localhost -e S3_FILENAME=latestbackup -e MULTI_FILES=yes davidegironi/docker-mysql-backup-restore-s3
To restore, the command is almost the same
docker run -e ACTION=restore -e MYSQLDUMP_DATABASE=test -e MYSQLDUMP_TODATABASE=newtest -e S3_ACCESSKEYID=awskey -e S3_SECRETACCESSKEY=awssecret -e S3_BUCKET=s3bucket -e S3_REGION=awsregion -e S3_PREFIX=backup -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_HOST=localhost -e S3_FILENAME=latestbackup -e MULTI_FILES=yes -davidegironi/docker-mysql-backup-restore-s3
Find the latest usage option and code in the github page of this small project here: https://github.com/davidegironi/docker-mysql-backup-restore-s3 

I'm using this on Fargate to backup and restore a managed MariaDB (RDS) without poblems.


Notes
  • read risk disclaimer
  • excuse my bad english