mongodump-stream
v1.1.1
Published
Various streaming utilities for dumping a mongo DB
Downloads
30
Readme
Mongo Dump Streaming Utilities
Obtain a stream object from mongo's export utility.
Heavily based off timisbusy/dumpstr
Documentation
var mds = require('mongodump-stream');
API
mds.slurp.binary(uri, collection)
Get a binary stream of your collection (mongodump).
mds.slurp.text(uri, collection)
Get a textual stream of your collection (mongoexport).
mds.dump.s3(key, stream, awsConf)
Write an object named key
to an S3 bucket using the data in stream
.
awsConf
must contain the properties key
, secret
, and bucket
.
mds.dump.fs.file(stream, path)
Dump stream into path.
Example
var mds = require('mongodump-stream');
var mongoUrl = 'mongodb://localhost:27017/YOUR-DB';
var mongoCollection = 'YOUR-COLLECTION';
var now = Date.now();
var fname = mongoCollection + '-' + now + '.bson';
var stream = mds.slurp.binary(mongoUrl, mongoCollection);
mds.dump.s3(fname, stream, {
key: process.env.AWS_ACCESS,
secret: process.env.AWS_SECRET,
bucket: process.env.AWS_S3_BUCKET
}).then(/* YOUR CALLBACKS */);
//
// You could also write it to a file
//
mds.dump.fs.file(stream, fname);