How to have MySQL backup with Docker?

Dockerized Ruby Backup Gem

I created a dockerized image for ruby gem backup/backup It was unfortunately older ruby where it worked flawlessly. Image can be found here varunbatrait/backup

If you are coming from Ruby, backup is a popular ruby gem which can be used to backup the database. Unfortunately it is maintenance only but it works flawlessly with current features. Since, it is not compatible with latest ruby, it makes sense to make a docker image of it.


I am assuming that you have configured the models inside models folder where you are right now. Then you can perform a trigger like this. Config can be an empty ruby file if you have everything mentioned in your model.

docker run --rm -v $(pwd):/usr/src/app  --user $(id -u):$(id -g) varunbatrait/backup:latest perform -t database_name --config-file config.rb --root-path . 


As usual, you can use alias and invoke it with just backup by using following:

alias backup='docker run --rm -it -v $(pwd):/usr/src/app  --user $(id -u):$(id -g) varunbatrait/backup:latest'

Provided you have added above alias to your .zshrc or .bashrc, You can generate a model – you can generate using:

backup generate:model --trigger=demo --config-file config.rb 

This will generate model file demo.rb under models/demo.rb

# encoding: utf-8

# Backup Generated: demo
# Once configured, you can run the backup with the following command:
# $ backup perform -t demo [-c <path_to_configuration_file>]
# For more information about Backup's components, see the documentation at:
#, 'Description for demo') do


For information related to usage of backup. Please visit official documentation

Worth Sharing?


  1. I used backup for quite some time but then it was lost in time. This post revivied the memory. I have been using docker image for S3. This one will definately go into my todo list.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>