Giter VIP home page Giter VIP logo

docker-mongodump's Introduction

tenorok/mongodumper

Docker image with mongodump running as a cron task.

Usage

Attach a target mongo container to this container and mount a volume to container /backup folder. The backups will appear in this volume as gzip-archives with names like 20170218_025718, where mask is %Y%m%d_%H%M%S.

Scheduled backups

docker run -d \
    -v /path/to/my-folder:/backup \     # path to put backups
    --link my-mongo-container:mongo \   # linked container with running mongo
    tenorok/mongodumper

Manual backup

To run manual backup without cron job, add no-cron parameter.

docker run --rm \
    -v /path/to/my-folder:/backup \
    --link my-mongo-container:mongo \
    tenorok/mongodumper no-cron         # manual start

Restore from backup

mongorestore --gzip --archive=/path/to/my-folder/20170218_025718

Option CRON_SCHEDULE

For customize backups schedule. Default schedule is 0 0 * * * โ€” runs every day at 00:00.

Recommend useful online helper for decoding crontab.

docker run -d \
    -v /path/to/my-folder:/backup \
    --link my-mongo-container:mongo \
    -e 'CRON_SCHEDULE=0 3 */5 * *' \   # custom cron job schedule
    tenorok/mongodumper

Option MONGO_DB_NAMES

For dump selective databases specify they names through space. This will create archives with names like 20170218_025718-db1 and 20170218_025718-db2 for each database from option.

Unfortunately now mongodump not providing opportunity to backups multiple databases at one time (TOOLS-22, TOOLS-31).

docker run -d \
    -v /path/to/my-folder:/backup \
    --link my-mongo-container:mongo \
    -e 'MONGO_DB_NAMES=db1 db2' \       # names (through space) of databases for dumping
    tenorok/mongodumper

Option BACKUP_EXPIRE_DAYS

For remove unnecessary archives older than specified number of days.

docker run -d \
    -v /path/to/my-folder:/backup \
    --link my-mongo-container:mongo \
    -e 'BACKUP_EXPIRE_DAYS=30' \        # number of days for remove old backups
    tenorok/mongodumper

Option BACKUP_FILE_NAME

For save backup with custom name. This option is more relevant for manual backup, because with scheduled backups file with specified name will overwritten each time.

docker run -d \
    -v /path/to/my-folder:/backup \
    --link my-mongo-container:mongo \
    -e 'BACKUP_FILE_NAME=express' \     # custom name for backup archive
    tenorok/mongodumper

Option MONGO_USERNAME, MONGO_PASSWORD

If your mongodb need user and password to access, you need set them in your environment.

docker run -d \
    -v /path/to/my-folder:/backup \
    --link my-mongo-container:mongo \
    -e 'MONGO_USERNAME=root' \          # mongo -u $MONGO_USERNAME
    -e 'MONGO_PASSWORD=rootpassword' \  # mongo -p $MONGO_PASSWORD
    tenorok/mongodumper

docker-mongodump's People

Contributors

istepanov avatar jonotron avatar tenorok 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.