Giter Site home page Giter Site logo

mongobackup's Introduction

#mongobackup

npm npm npm

A Grunt and Gulp compatible plugin to import or export MongoDb data by launching a child process, passing the commands for mongodump and mongorestore MongoDB Package Components.

This plugin is similar to grunt-mongo-backup in that it spawns a child process. The difference in mongobackup is that it is compatible with both Grunt and Gulp. Another difference of mongobackup is that it provides a means to pass separate options for both dump and restore operations.

Installation

Install package with NPM and add it to your development dependencies:

$ npm install mongobackup --save-dev

Support

As this plugin depends on the node child_process module and the spawn method, it doesn't yet support Windows systems.

Tested on MongoDB 3.2 >.

Usage

Grunt

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('mongobackup');

Configure via grunt.initConfig().

grunt.initConfig({
  mongobackup: {
    dump : {
      options: {
        host : 'localhost',
        out : './dumps/mongo'
      }
    },
    restore: {
      options: {
        db : 'testdb',
        host : 'localhost',
        drop : true,
        path : './dumps/mongo/testdb'
      }
    }
  }
});

Then run:

$ grunt mongobackup:dump

Or:

$ grunt mongobackup:restore

Gulp

var mongobackup = require('mongobackup');

// mongodump - dump all databases on localhost
gulp.task('mongodump', function() {
  mongobackup.dump({
    host : 'localhost',
    out : './dumps/mongo'
  });
});

// mongorestore - restore 'testdb' database to localhost
gulp.task('mongorestore', function() {
  mongobackup.restore({
    db : 'testdb',
    host : 'localhost',
    drop : true,
    path : './dumps/mongo/testdb'
  });
});

Then run:

$ gulp mongodump

Or:

$ gulp mongorestore

Options

  • Any provided options (such as host, out, etc) are passed as arguments to mongodump and mongorestore. All arguments available in these two MongoDB Package Components are available as options. The boolean value true should be used for free standing arguments that don't accept a value, per the docs linked above.

mongobackup's People

Contributors

adamhenson avatar

Watchers

Rodney Solomon avatar James Cloos 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.