Coder Social home page Coder Social logo

ferios08 / mysql-backerup Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 9 KB

A docker image to automaically backup your MySQL databases through cronjobs to an external volume

License: Apache License 2.0

Dockerfile 9.95% Shell 90.05%
docker mysql cronjob backup restore

mysql-backerup's Introduction

mysql-backup

This image runs mysqldump to backup data using cronjob to folder /mysql-backup

For a prebuilt version of this Docker image, you can use mine: firasdotcom/mysql-backerup

Usage

docker run -d --name mysql-backerup \
    --env MYSQL_HOST=mysql.host \
    --env MYSQL_PORT=3306 \
    --env MYSQL_USER=admin \
    --env MYSQL_PASS=password \
    --volume host.folder:/mysql-backup \
    mysql-backerup

Moreover, if you link mysql-backerup to a mysql container(e.g. mysql) with an alias named mysql, this image will try to auto load the host, port, user, pass if possible.

docker run -d -p 3306:3306  -e MYSQL_PASS="mypass" --name mysql mysql
docker run -d --link mysql:mysql -v host.folder:/mysql-backup mysql-backerup

Parameters

MYSQL_HOST          the host/ip of your mysql database
MYSQL_PORT          the port number of your mysql database
MYSQL_USER          the username of your mysql database
MYSQL_PASS          the password of your mysql database
MYSQL_DB            the database name to dump. Default: `--all-databases`
EXTRA_OPTS          the extra options to pass to mysqldump command
COMPRESS            if set, compress the backup using `COMPRESS_CMD`
COMPRESS_CMD        the compress command used to compress the dump. Default: `gzip`
CRON_TIME           the interval of cron job to run mysqldump. `0 0 * * *` by default, which is every day at 00:00
MAX_BACKUPS         the number of backups to keep. When reaching the limit, the old backup will be discarded. No limit by default
INIT_BACKUP         if set, create a backup when the container starts
INIT_RESTORE_LATEST if set, restores latest backup

Restore from a backup

See the list of backups, you can run:

docker exec mysql-backerup ls /mysql-backup

To restore database from a certain backup:

-Restoring a specific database:

docker exec mysql-backerup /restore.sh [db_to_restore] [backupfile]

-Full restore:

docker exec mysql-backerup /restore.sh [backupfile]

mysql-backerup's People

Watchers

James Cloos avatar Firas Chbiki 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.