mongodb-snapshot (v1.4.1) is a TypeScript-first library for dumping and restoring MongoDB databases between various data sources, including local files and other MongoDB instances. It provides a streaming, promise-based transfer mechanism using duplex connectors, with support for progress tracking via async iterators. The package is actively maintained on GitHub with monthly releases, and ships its own TypeScript definitions. Compared to mongodump/mongorestore, it offers programmatic control and in-process streaming without shell commands, and supports multi-target transfers (fan-out) efficiently. All operations require MongoDB instance access and local filesystem write permissions.
npm install mongodb-snapshotNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Dumps a MongoDB database to a local .tar file using streaming connectors and progress reporting.
Set 'type': 'module' in package.json or use .mjs extension.
Ensure URI includes username:password@host:port/dbname or use a connection string with proper credentials.
Ensure compatible MongoDB server version (4.0+) and driver version (mongodb ^5.x).
Always await the async iteration: for await (const progress of transferer) {...}Change to 'import { MongoTransferer } from 'mongodb-snapshot' and ensure package.json has type: module.Ensure connection.uri starts with 'mongodb://' or 'mongodb+srv://'.
Drop or clear the target collection before restore, or adjust the dump to exclude duplicates.