Registry / database / mongodb-restore

mongodb-restore

JSON →
library1.6.2jsnpmunverified

A Node.js library to restore MongoDB dump data created by mongodb-backup. Version 1.6.2 supports BSON and JSON parsers, tar archives, streaming, and collection dropping. It provides a callback-based API for programmatic restore, complementing the CLI tool mongodb-restore-cli. Notable for being the restore counterpart of mongodb-backup, with support for metadata replication and custom parsers. Release cadence is sporadic with infrequent updates.

npm install mongodb-restore
INSTALL
IMPORT
SIG · MONGODB-RESTORE
M
mongodb-restore
databasejavascriptv1.6.2
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.

default
const restore = require('mongodb-restore')
CommonJS only. No ES module support.
restore (function)
import restore from 'mongodb-restore'
import { restore } from 'mongodb-restore'
No named export; use default import in ESM (requires module wrapper).
restore (callback)
restore(options, callback)
restore(options, (err, result) => {})
Callback is optional; if omitted, errors are thrown.

Demonstrates basic usage of mongodb-restore with BSON parser and drop option.

const restore = require('mongodb-restore'); restore({ uri: 'mongodb://localhost:27017/mydb', root: __dirname + '/backup/dbName', parser: 'bson', drop: true, callback: function(err) { if (err) { console.error('Restore failed:', err); } else { console.log('Restore completed successfully'); } } });
Debug
Known issues
breakingBson@0.4.11 pulled out, versions >=1.3.0 and <=1.4.1 are deprecated
fix
Upgrade to 1.4.2 or later (or use 1.2.x).
affects: >=1.3.0 <=1.4.1
deprecatedThe `parser` option accepts string 'bson' or 'json' - ensure compatibility with your backup format.
fix
Use only 'bson' or 'json' as string, or provide a custom function.
affects: <1.6.0
gotchaIf `drop` or `dropCollections` is set to true, existing collections will be dropped before restore.
fix
Verify target database contents before enabling drop.
affects: >=0.0.0
gotchaThe `root` path must point to a directory with backup files in the format produced by mongodb-backup.
fix
Ensure backup was created with the companion package mongodb-backup.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mongodb-restore'
Package not installed.
fix
Run `npm install mongodb-restore`
TypeError: restore is not a function
Incorrect import in ES module context.
fix
Use `const restore = require('mongodb-restore')` (CJS) or wait for ESM wrapper.
MongoError: Authentication failed
URI credentials are incorrect or user lacks permissions.
fix
Check uri string: mongodb://user:password@host:port/db
Upgrade
Version history
1.6.2latest on npm
Audit
Dependencies
mongodbrequiredMongoDB driver for database operations
asyncrequiredControl flow for asynchronous operations
Agent activity
5 hits · last 30 days
node
4
Resources
mongodb-restore — npm install mongodb-restore · libregistry