Giter Club home page Giter Club logo

mysql-docker-backuper's Introduction

MySQL Docker Backuper

Docker image for making backups of mysql/mariadb databases and export to AWS S3. It export gzipped backup to AWS S3.

This is a simple project for backup to S3. It can easily be adapted for other services (Digital Ocean Spaces, Azure Blob Storage...). I use only S3 for this, but if anyone need for another service, create an issue and let's to it :)

Running

Start a new service passing the required parameters.

docker service create \
    --env DB_USER=$DB_USER \
    --env DB_PASSWORD=$DB_PASSWORD \
    --env DB_DATABASE=$DB_DATABASE \
    --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
    --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
    --env AWS_BUCKET=$AWS_BUCKET \
    --network my-network \
    rafaelhdr/mysql-docker-backuper:0.2

Parameters

  • DB_USER
  • DB_PASSWORD
  • DB_DATABASE
  • DB_HOST
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_BUCKET - The name of the bucket, but can append a path, for example mybucket/path/to/some/directory
  • SCHEDULE_CRON (Optional) - Crontab format scheduler. Keeps the service alive. Example for once a day 0 4 * * *

Example

Set AWS environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_BUCKET) and run the commands below:

docker network create -d bridge my-network

docker run \
    -d \
    --rm \
    --name my-db-host \
    --env MYSQL_ROOT_PASSWORD=my-password \
    --env MYSQL_DATABASE=my-db \
    --network my-network \
    mysql:8.0

docker run \
    -d \
    --rm \
    --name my-backuper \
    --env DB_HOST=my-db-host \
    --env DB_USER=root \
    --env DB_PASSWORD=my-password \
    --env DB_DATABASE=my-db \
    --env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
    --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
    --env AWS_BUCKET=$AWS_BUCKET \
    --network my-network \
    rafaelhdr/mysql-docker-backuper:0.2

Check the database backup at your AWS S3.

mysql-docker-backuper's People

Contributors

rafaelhdr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.