Registry / database / mongobackup

mongobackup

JSON →
library0.3.5jsnpmunverified

A Grunt and Gulp compatible plugin for importing and exporting MongoDB data via child process spawning of mongodump, mongorestore, mongoimport, and mongoexport. Version 0.3.5 is the latest stable release. It wraps MongoDB command-line tools into task runners, allowing configuration of dump, restore, import, and export operations. Key differentiators: supports both Grunt and Gulp, and allows separate options for dump and restore. Does not support Windows, requires MongoDB tools installed.

npm install mongobackup
INSTALL
IMPORT
SIG · MONGOBACKUP
M
mongobackup
databasejavascriptv0.3.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mongobackup
const mongobackup = require('mongobackup');
import mongobackup from 'mongobackup';
CommonJS module. Use require(), not ES import.
dump
mongobackup.dump({options});
mongobackup.dump();
dump method requires an options object.
restore
mongobackup.restore({options});
mongobackup.restore();
restore method requires an options object.

Demonstrates using mongobackup with Gulp to dump and restore MongoDB databases.

// Install: npm install mongobackup --save-dev // Gulp example const gulp = require('gulp'); const mongobackup = require('mongobackup'); gulp.task('mongodump', function() { mongobackup.dump({ host: 'localhost', out: './dumps/mongo' }); }); gulp.task('mongorestore', function() { mongobackup.restore({ db: 'testdb', host: 'localhost', drop: true, path: './dumps/mongo/testdb' }); }); // Run: gulp mongodump
Debug
Known issues
gotchamongobackup spawns child processes for MongoDB tools. Ensure mongodump, mongorestore, mongoimport, and mongoexport are installed and in PATH.
fix
Install MongoDB Database Tools from mongodb.com.
affects: >=0.0.0
gotchaThis plugin does not support Windows systems due to child_process.spawn limitations.
fix
Use on Linux or macOS, or find a cross-platform alternative.
affects: >=0.0.0
gotchaOptions object properties are directly passed as command-line arguments. Boolean true for flag arguments (e.g., drop: true) will become --drop.
fix
Set boolean options to true for flags, not to empty string.
affects: >=0.0.0
Errors
Common errors & fixes
Error: spawn mongodump ENOENT
mongodump not installed or not in PATH.
fix
Install MongoDB Database Tools and ensure they are accessible from command line.
TypeError: mongobackup.dump is not a function
Importing the module incorrectly (e.g., using ES import instead of require).
fix
Use const mongobackup = require('mongobackup');
Error: spawn mongodump EACCES
MongoDB tools executable does not have execute permission.
fix
Run chmod +x on the tool binaries, e.g., chmod +x /usr/bin/mongodump.
Upgrade
Version history
0.3.5latest on npm
Audit
Dependencies
gruntoptionalRequired for Grunt integration when used as a Grunt plugin
Agent activity
5 hits · last 30 days
node
4
Resources
mongobackup — npm install mongobackup · libregistry