Coder Social home page Coder Social logo

baozdemir / docker-mongodb-worker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drizztguen77/docker-mongodb-worker

0.0 2.0 0.0 11 KB

Docker image that provides capability to perform native Mongodb binary and data import/export

Dockerfile 10.60% Shell 89.40%

docker-mongodb-worker's Introduction

docker-mongodb-worker

Docker image that provides capability :

  • to perform native Mongodb binary and data import/export
  • backup dump of the database

Description

Parameters

MONGO_HOST              the host/ip of your mongodb database
MONGO_PORT              the port number of your mongodb database
MONGO_DB_NAME           the database name
MONGO_COLLECTION_NAME   the database collection to work on, according to the MONGO_DB_NAME provided
MONGO_BACKUP_FILENAME   the name of the generated file
CRON_SCHEDULE           the interval of cron job to run mongodump

In order to specify the willing action, you must override the default docker command. The running container requires the following environments variables :

  • Require for every jobs:

    • MONGO_HOST, MONGO_PORT
  • Require for Export :

    • MONGO_DB_NAME, MONGO_COLLECTION_NAME, MONGO_BACKUP_FILENAME
  • Require for Import:

    • MONGO_DB_NAME, MONGO_COLLECTION_NAME
  • Require for Dump:

    • MONGO_BACKUP_FILENAME
  • Require for Restore:

    • MONGO_BACKUP_FILENAME

Usage

This container is designed to perform operations on a running mongoDB instance.

Import

To import json data, this container assumed that the filename is import.json.

If YOUR_PATH/import.json is the location of the import file :

      docker run \
            -v YOUR_PATH/:/tmp/mongodb/  \
            -e MONGO_HOST=your_host_value \
            -e MONGO_PORT=your_port_value \
            -e MONGO_DB_NAME=your_db_name \
            -e MONGO_COLLECTION_NAME=your_collection_name \
            drizztguen77/docker-mongodb-worker \
            /start.sh -i

Export

  • With cron

        docker run \
              -e MONGO_HOST=your_host_value \
              -e MONGO_PORT=your_port_value \
              -e MONGO_DB_NAME=your_db_name \
              -e MONGO_COLLECTION_NAME=your_collection_name \
              -e CRON_SCHEDULE=your_cron_schedule \
              -e MONGO_BACKUP_FILENAME=your_backup_filename_without_extension \
              drizztguen77/docker-mongodb-worker \
              /start.sh -e cron
    
  • Without cron ( direct export)

        docker run \
              -e MONGO_HOST=your_host_value \
              -e MONGO_PORT=your_port_value \
              -e MONGO_DB_NAME=your_db_name \
              -e MONGO_COLLECTION_NAME=your_collection_name \
              -e MONGO_BACKUP_FILENAME=your_backup_filename_without_extension \
              drizztguen77/docker-mongodb-worker \
              /start.sh -e no-cron
    

Dump

  • To backup the database

  • With cron

        docker run \
              -e MONGO_HOST=your_host_value \
              -e MONGO_PORT=your_port_value \
              -e CRON_SCHEDULE=your_cron_schedule \
              -e MONGO_BACKUP_FILENAME=your_backup_filename_without_extension \
              drizztguen77/docker-mongodb-worker \
              /start.sh -d cron
    
  • Without cron ( direct dump)

        docker run \
              -e MONGO_HOST=your_host_value \
              -e MONGO_PORT=your_port_value \
              -e MONGO_BACKUP_FILENAME=your_backup_filename_without_extension \
              drizztguen77/docker-mongodb-worker \
              /start.sh -d no-cron
    

Restore

  • To restore the database

        docker run \
              -e MONGO_HOST=your_host_value \
              -e MONGO_PORT=your_port_value \
              -e MONGO_BACKUP_FILENAME=your_backup_filename_without_extension \
              drizztguen77/docker-mongodb-worker \
              /start.sh -r no-cron
    

Backup Data

For export and dump ,the backup data will be hosted into /backup/

Example

Easy to use with docker-compose , go into the example

  • run docker-compose -f example.yml
  • Every minute, we will see a .json file and a .tar from export and dump into example/data/ directory

docker-mongodb-worker's People

Contributors

bwnyasse avatar drizztguen77 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.