A Node.js library (v1.0.8) for backing up and restoring MongoDB databases using Mongoose. It exports all collections as JSON files to a specified directory and restores them by reading and inserting those files. Different from mongodump/restore by being a pure-JS solution with no CLI dependency. Intermittent updates with basic functionality; not actively maintained.
npm install mongodb-backup-toolkitNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates ESM import, backup and restore using default export, with environment variable for URI.
Ensure the restore operation is intended to replace all data, or modify the source code to handle upsert instead.
Check compatiblity; may need to use older Mongoose or fork the package.
Ensure the MongoDB URI has correct credentials and that the IP is whitelisted in Atlas.
Run the backup with a dedicated user or manually set permissions after backup.
Use mongodump for large databases or implement streaming in a custom script.
Use import instead of require, or use dynamic import() in CJS context.
Use default import: import MongoBackupToolkit from 'mongodb-backup-toolkit' then call MongoBackupToolkit.backup().
Ensure the URI is provided as a string, e.g., const uri = process.env.MONGO_URI ?? 'mongodb://localhost:27017/mydatabase';
Verify the backup path and that the files exist. Use an absolute path or ensure the directory is correctly created.