Registry / database / mongodb-backup-restore

mongodb-backup-restore

JSON →
library0.3.1jsnpmunverified

MongoDB Backup Restore (mongodb-backup-restore v0.3.1) is a Node.js library for backing up and restoring MongoDB databases using a JSON configuration. It wraps the mongodb-backup and mongodb-restore packages to provide a unified interface. Development appears slow with no recent updates. Key features include configuring backup and restore independently, appending strings to database names during restore, and support for MongoDB connection options like SSL. It requires a MongoDB client and is intended for migration and backup tasks.

npm install mongodb-backup-restore
INSTALL
IMPORT
SIG · MONGODB-BACKUP-RES
M
mongodb-backup-restore
databasejavascriptv0.3.1
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.

MongoDBBackupRestore
import mongodbBackupRestore from 'mongodb-backup-restore';
const { MongoDBBackupRestore } = require('mongodb-backup-restore');
Default export is a function, not a named export. CommonJS require returns the function directly.
mongodbBackupRestore
const mongodbBackupRestore = require('mongodb-backup-restore');
CommonJS require works as the package provides a single default function.
backupRestore
import backupRestore from 'mongodb-backup-restore';
import { backupRestore } from 'mongodb-backup-restore';
There is no named export 'backupRestore'; use default import.

Demonstrates backup and restore of a MongoDB database with SSL and database name appending.

const mongodbBackupRestore = require('mongodb-backup-restore'); const config = { projectName: 'MyProject', doBackup: true, doRestore: true, origin: { url: 'mongodb://user:password@hostname.com:27017', databases: ['myDatabase'], mongodbOptions: { ssl: true, authSource: 'admin' } }, target: { url: 'mongodb://localhost:27017', mongodbOptions: { ssl: false }, useOriginDatabases: true, databases: [], dbNameAppend: 'Copy' } }; (async () => { try { await mongodbBackupRestore(config); console.log('Backup and restore completed successfully'); } catch (err) { console.error('Error:', err.message); } })();
Debug
Known issues
breakingConfiguration structure may change without major version bump due to low version number.
fix
Pin version and test thoroughly before upgrading.
affects: <=0.3.1
gotchaThe package is a thin wrapper over mongodb-backup and mongodb-restore. Those packages may have their own breaking changes.
fix
Check dependencies for known issues.
affects: all
deprecatedPackage has not been updated since 2019; underlying dependencies may be outdated.
fix
Consider using native mongodump/mongorestore or more actively maintained alternatives like mongodb-memory-server for testing.
affects: all
gotchaThe origin.databases and target.databases arrays are required but can be empty when using useOriginDatabases.
fix
Ensure arrays are present even if empty.
affects: all
gotchaThe mongodbOptions in origin and target are not validated; incorrect SSL settings may lead to connection failures.
fix
Double-check MongoDB connection options for each environment.
affects: all
breakingIf the internal mongodb-backup or mongodb-restore packages introduce breaking changes, this wrapper may not be updated promptly.
fix
Monitor those packages for changes.
affects: <=0.3.1
Errors
Common errors & fixes
TypeError: libMongodbBackupRestore is not a function
Using named import from CommonJS module instead of default import.
fix
Use `const mongodbBackupRestore = require('mongodb-backup-restore');` or `import mongodbBackupRestore from 'mongodb-backup-restore';`
Error: Cannot find module 'mongodb-backup'
The dependency mongodb-backup is missing or not installed.
fix
Run `npm install mongodb-backup mongodb-restore` to ensure all dependencies are present.
MongoNetworkError: failed to connect to server [hostname.com:27017]
Invalid connection string or network issues.
fix
Verify the origin.url and target.url are correct, and check network/firewall settings.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
mongodb-backuprequiredused internally for backup operations
mongodb-restorerequiredused internally for restore operations
Agent activity
9 hits · last 30 days
node
8
Resources