Registry / database / mongodb-backup-dump

mongodb-backup-dump

JSON →
library1.0.3jsnpmunverified

A simple Node.js package to backup, restore, and schedule MongoDB database snapshots using mongodump and mongorestore. Current stable version: 1.0.3 (infrequently updated). It wraps native MongoDB CLI tools, offering a simplified API for common backup operations and cron-based scheduling. Compared to alternatives like mongodump directly or mongodb-backup, this package adds minimal abstraction but lacks authentication support, TLS/SSL, and cloud storage options.

npm install mongodb-backup-dump
INSTALL
IMPORT
SIG · MONGODB-BACKUP-DUM
M
mongodb-backup-dump
databasejavascriptv1.0.3
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 mongodbBackup = require('mongodb-backup-dump')
import mongodbBackup from 'mongodb-backup-dump'
This package does not provide ESM exports. Use CommonJS require(). A default import will not work in Node.js without a synthetic default.
createBackup
mongodbBackup.createBackup(host, port, backupDest)
createBackup(host, port, backupDest)
createBackup is a method on the default export, not a named export.
restoreBackup
mongodbBackup.restoreBackup(path, host, port)
const { restoreBackup } = require('mongodb-backup-dump')
restoreBackup is only accessible via the default export object.
scheduleBackup
mongodbBackup.scheduleBackup(cronExpression, host, port, backupDest)
import { scheduleBackup } from 'mongodb-backup-dump'
scheduleBackup is also a method on the default export.

Demonstrates basic backup, restore, and scheduled backup using mongodb-backup-dump with both default and custom parameters.

const mongodbBackup = require('mongodb-backup-dump'); // Create a backup with default settings (localhost:27017, destination ./backup/<currentDate>) mongodbBackup.createBackup(); // Restore from a backup folder (default host:localhost, port:27017) mongodbBackup.restoreBackup('./myBackup'); // Schedule backup daily at 2 AM (cron: minute hour day month weekday) mongodbBackup.scheduleBackup('0 2 * * *'); // Custom host, port, and destination mongodbBackup.createBackup('192.168.1.08', 27017, 'myBackup'); mongodbBackup.restoreBackup('./myBackup', '192.168.1.08', 27017); mongodbBackup.scheduleBackup('* * 1 * * *', '192.168.1.08', 27017, 'myBackup');
Debug
Known issues
gotchaNo authentication support: The package does not accept username/password or connection strings. Backups will fail on protected MongoDB instances.
fix
Use mongodump/mongorestore directly with --username and --password flags, or use a more comprehensive backup solution.
affects: >=1.0.0
deprecatedUsing bower for installation: Bower is deprecated and no longer maintained.
fix
Install via npm or yarn only.
affects: >=1.0.0
gotchaMissing error handling in examples: The quickstart examples do not show error handling. If mongodump or mongorestore are not installed, the methods throw unhandled errors.
fix
Wrap calls in try/catch blocks or use .catch() if promises are involved (note: the package uses callbacks, not promises).
affects: >=1.0.0
gotchaHardcoded backup path: The backup destination defaults to './backup/<date>'. If the directory does not exist, the backup may fail on some systems.
fix
Ensure the parent directory exists or use an absolute path for the backupDest parameter.
affects: >=1.0.0
Errors
Common errors & fixes
Error: spawn mongodump ENOENT
mongodump is not installed or not in the system PATH.
fix
Install MongoDB Database Tools (mongodump and mongorestore) and ensure they are in your PATH.
Cannot find module 'cron'
The optional 'cron' dependency is missing. However, it is listed as a dependency, so this error may occur if npm install failed.
fix
Run 'npm install' again, or manually install 'npm install cron@1.8.2' (the version used by this package).
TypeError: mongodbBackup.createBackup is not a function
Using a named import instead of the default export (e.g., import { createBackup } from 'mongodb-backup-dump').
fix
Use the default require: const mongodbBackup = require('mongodb-backup-dump'); then call mongodbBackup.createBackup().
Error: connect ECONNREFUSED 127.0.0.1:27017
MongoDB is not running on the expected host/port.
fix
Start MongoDB (mongod) or specify a correct host and port.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
cronrequiredUsed for scheduling backup tasks. A runtime dependency.
Agent activity
9 hits · last 30 days
node
8
Resources
mongodb-backup-dump — npm install mongodb-backup-dump · libregistry