Giter Site home page Giter Site logo

jkyberneees / mongodb-backup-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from halvves/mongodb-backup-s3

0.0 0.0 0.0 19 KB

Docker image that regularly backs up a MongoDB instance into an s3 bucket

Home Page: https://hub.docker.com/r/halvves/mongodb-backup-s3/

License: Apache License 2.0

Shell 94.61% Dockerfile 5.39%

mongodb-backup-s3's Introduction

mongodb-backup-s3

This image runs mongodump to backup data using cronjob to an s3 bucket

Usage:

docker run -d \
  --env AWS_ACCESS_KEY_ID=awsaccesskeyid \
  --env AWS_SECRET_ACCESS_KEY=awssecretaccesskey \
  --env BUCKET=s3bucket
  --env MONGODB_HOST=mongodb.host \
  --env MONGODB_PORT=27017 \
  --env MONGODB_USER=admin \
  --env MONGODB_PASS=password \
  halvves/mongodb-backup-s3

If you link halvves/mongodb-backup-s3 to a mongodb container with an alias named mongodb, this image will try to auto load the host, port, user, pass if possible. Like this:

docker run -d \
  --env AWS_ACCESS_KEY_ID=myaccesskeyid \
  --env AWS_SECRET_ACCESS_KEY=mysecretaccesskey \
  --env BUCKET=mybucketname \
  --env BACKUP_FOLDER=a/sub/folder/path/ \
  --env INIT_BACKUP=true \
  --link my_mongo_db:mongodb \
  halvves/mongodb-backup-s3

Add to a docker-compose.yml to enhance your robotic army:

For automated backups

mongodbbackup:
  image: 'halvves/mongodb-backup-s3:latest'
  links:
    - mongodb
  environment:
    - AWS_ACCESS_KEY_ID=myaccesskeyid
    - AWS_SECRET_ACCESS_KEY=mysecretaccesskey
    - BUCKET=my-s3-bucket
    - BACKUP_FOLDER=prod/db/
  restart: always

Or use INIT_RESTORE with DISABLE_CRON for seeding/restoring/starting a db (great for a fresh instance or a dev machine)

mongodbbackup:
  image: 'halvves/mongodb-backup-s3:latest'
  links:
    - mongodb
  environment:
    - AWS_ACCESS_KEY_ID=myaccesskeyid
    - AWS_SECRET_ACCESS_KEY=mysecretaccesskey
    - BUCKET=my-s3-bucket
    - BACKUP_FOLDER=prod/db/
    - INIT_RESTORE=true
    - DISABLE_CRON=true

Parameters

AWS_ACCESS_KEY_ID - your aws access key id (for your s3 bucket)

AWS_SECRET_ACCESS_KEY: - your aws secret access key (for your s3 bucket)

BUCKET: - your s3 bucket

BACKUP_FOLDER: - name of folder or path to put backups (eg myapp/db_backups/). defaults to root of bucket.

MONGODB_HOST - the host/ip of your mongodb database

MONGODB_PORT - the port number of your mongodb database

MONGODB_USER - the username of your mongodb database. If MONGODB_USER is empty while MONGODB_PASS is not, the image will use admin as the default username

MONGODB_PASS - the password of your mongodb database

MONGODB_DB - the database name to dump. If not specified, it will dump all the databases

EXTRA_OPTS - any extra options to pass to mongodump command

CRON_TIME - the interval of cron job to run mongodump. 0 3 * * * by default, which is every day at 03:00hrs.

TZ - timezone. default: US/Eastern

CRON_TZ - cron timezone. default: US/Eastern

INIT_BACKUP - if set, create a backup when the container launched

INIT_RESTORE - if set, restore from latest when container is launched

DISABLE_CRON - if set, it will skip setting up automated backups. good for when you want to use this container to seed a dev environment.

Restore from a backup

To see the list of backups, you can run:

docker exec mongodb-backup-s3 /listbackups.sh

To restore database from a certain backup, simply run (pass in just the timestamp part of the filename):

docker exec mongodb-backup-s3 /restore.sh 20170406T155812

To restore latest just:

docker exec mongodb-backup-s3 /restore.sh

Acknowledgements

mongodb-backup-s3's People

Contributors

alexguzun avatar brunobertolini avatar fermayo avatar futurist avatar halvves avatar thexperiments avatar tifayuki 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.