1.7.2 • Published 4 years ago

mongodb-backup-fixed v1.7.2

Weekly downloads
12
License
Apache-2.0
Repository
github
Last release
4 years ago

mongodb-backup-fixed

Since hex7c0 give up maintained the project,I had to fixed the bug myself.Just share why it didn't work.

MongoDB deperecated the method snapshot(),so we have to modify our function.
Document

Wrong code: var stream = collection.find(query).snapshot(true).stream();
Correct code: var stream = collection.find({$query:query, $snapshot:true}).stream();

quick start: npm install mongodb-backup-fixed

Below here is original document

NPM version Linux Status Windows Status Dependency Status Coveralls

Backup for mongodb

Look at mongodb-backup-cli for command line usage, similar to mongodump

Look at mongodb-restore for restore data

Installation

Install through NPM

npm install mongodb-backup

or

git clone git://github.com/hex7c0/mongodb-backup.git

Bson@0.4.11 has been pulled out, so versions >= 1.3.0 and <= 1.4.1 are deprecated

API

inside nodejs project

var backup = require('mongodb-backup');

backup({
  uri: 'uri', // mongodb://<dbuser>:<dbpassword>@<dbdomain>.mongolab.com:<dbport>/<dbdatabase>
  root: __dirname
});

backup(options)

options

  • uri - String URI for MongoDb connection (default "required")
  • root- String Path where save data (default "required")
  • [parser] - String | Function Data parser (bson, json) or custom (default "bson")
  • [collections] - Array Select which collections save (default "disabled")
  • [callback] - Function Callback when done (default "disabled")
  • [stream]- Object Send .tar file to Node stream (default "disabled")
  • [tar] - String Pack files into a .tar file (default "disabled")
  • [query] - Object Query that optionally limits the documents included (default "{}")
  • [numCursors] - Number Set number of cursor for parallelCollectionScan without query (default "disabled")
  • [logger] - String Path where save a .log file (default "disabled")
  • [metadata] - Boolean Save metadata of collections as Index, ecc (default "false")
  • [options] - Object MongoDb options (default)

Examples

Take a look at my examples

License Apache2