0.0.3 • Published 9 years ago

aws-mongodump v0.0.3

Weekly downloads
3
License
BSD
Repository
github
Last release
9 years ago

aws-mongodump

A node.js package to dump mongodb (mongodump) directly into s3 without filling up your local disk in the process.

NOTE: This is still a work in progress. Please don't rely on it as your only backup option, especially without some decent testing.

NOTE 2: You may need to upgrade your version of mongodump (by upgrading mongo) due to this issue: https://jira.mongodb.org/browse/SERVER-5233

Install

npm install aws-mongodump

Use

var dump = require('aws-mongodump').dump;

var now = +new Date(); // gives the current time as a number

dump("MY_MONGO_URI", "mongobackup-" + now, function (err, res) {
  if (err) { throw err; }
  console.log('results: ', res);
});

By default, dumpstr will check for a file in your working directory called "conf.js", which should look something like this.

// This file is called conf.js
module.exports = {
  aws: {
    key: "MY_KEY_IS_HERE"
  , secret: "THIS_IS_SECRET_HERE"
  , bucket: "I_HAS_A_BUCKET"
  }
}

You can also update that path using setConfig.

var md = require('dumpstr')
, dump = md.dump;

md.setConfig("my_config_path/is_better.js");

Or you can supply a json config object directly using setConfigJson.

var md = require('dumpstr')
, dump = md.dump;

md.setConfigJson(json);

If you want to keep your configs in environment variables instead (Who could blame you?), go ahead and set these instead. That way you can leave out the config file entirely.

AWS_KEY
AWS_SECRET
AWS_BUCKET

Thanks

@timisbusy for the providing pretty much all of this code base, added convict (json) config options and updated logger.