Skip to content

s-manzhak/mysql-backup-restore

 
 

Repository files navigation

mysql-backup-restore

Service to backup and/or restore mysql databases to/from S3

How to use it

  1. Create an S3 bucket to hold your backups
  2. Turn versioning on for that bucket
  3. Supply all appropriate environment variables
  4. Run a backup and check your bucket for that backup

Environment variables

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.

Docker Hub

This image is built automatically on Docker Hub as silintl/mysql-backup-restore.

Playing with it locally

You'll need Docker, Docker Compose, and Make.

  1. cd .../mysql-backup-restore
  2. Upload test/world.sql.gz to the S3 bucket.
  3. make db # creates the MySQL DB server
  4. make restore # restores the DB dump file
  5. docker ps -a # get the Container ID of the exited restore container
  6. docker logs <containerID> # review the restoration log messages
  7. make backup # create a new DB dump file
  8. docker ps -a # get the Container ID of the exited backup container
  9. docker logs <containerID> # review the backup log messages
  10. make restore # restore the DB dump file from the new backup
  11. docker ps -a # get the Container ID of the exited restore container
  12. docker logs <containerID> # review the restoration log messages
  13. make clean # remove containers and network
  14. docker volume ls # find the volume ID of the MySQL data container
  15. docker volume rm <volumeID> # remove the data volume
  16. docker images # list existing images
  17. docker image rm <imageID ...> # remove images no longer needed

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 85.3%
  • Dockerfile 10.4%
  • Makefile 4.3%