Putting together a data rescue strategy with mongodump and mongorestore for logical backups, filesystem snapshots for physical backups, point-in-time restore in Atlas, and listening to data changes in real time with change streams.

There's no better rating for backup success than a data-loss test. Production applications always face bad scenarios: human error deleting a collection, a bug overwriting thousands of documents, or a server burning out. In that situation, you don't need excuses — you need a backup that can be restored. Episode 18 prepares you for that moment.
The roadmap: first the backup/restore strategy — mongodump/mongorestore for logical backups, second filesystem snapshots for physical backups, third point-in-time restore in Atlas, and fourth change streams for listening to data changes in real time — a skill that opens the door to event-driven architecture. Let's get started.
mongodump produces a logical backup — data exported as BSON files containing documents and metadata. It's the most flexible because you can choose the level: a whole database, specific collections, even with a query filter:
mongodump --uri "mongodb://localhost:27017" --db app --out /backup/app-2026-08-03mongodump --uri "mongodb://localhost:27017" \
--db app --collection orders \
--query '{ "status": "paid" }' \
--out /backup/orders-paidThe result is a folder containing .bson and .metadata.json files per collection. Restoration uses mongorestore — you can restore everything, or a single collection:
mongorestore --uri "mongodb://localhost:27017" --drop /backup/app-2026-08-03mongorestore --uri "mongodb://localhost:27017" \
--db app --collection orders \
/backup/app-2026-08-03/app/orders.bsonThe --drop option deletes the collection before restoring — be careful, use it only when you really want to replace existing data.
It's important to understand: mongodump takes a consistent snapshot when run against a replica set (with --oplog for point-in-time consistency), but this is not a continuous backup — there's a window of data arriving after the dump completes that isn't captured.
A filesystem snapshot is a physical copy of the entire data directory at the OS/disk level — using LVM, ZFS, or cloud disk snapshots. Its advantages:
lvcreate -L 20G -s -n mongo-snap /dev/vg/mongodata
mount /dev/vg/mongo-snap /mnt/backupFor perfect consistency, take snapshots on a replica set and grab them from a secondary — so the primary isn't disturbed and the data is guaranteed in sync from the same point in time.
If you use MongoDB Atlas (SaaS), backups are managed automatically: continuous backup captures data changes almost in real time, enabling Point-in-Time Restore — restoring a cluster to its state at a specific minute (even second). This is invaluable when you need to rewind to just before a mistake happened, without losing the data that arrived afterward.
Atlas also performs routine snapshots (e.g. every 6 hours) with varying retention, and the entire process is managed via the UI or API without manual scripts. The trade-off: you pay for the service, and the data isn't available as freely portable files.
Change streams let applications listen to data changes on a collection, database, or the entire deployment in real time — inserts, updates, replaces, and deletes. This is the bridge from a "passive" database to an "active" one that tells the application when data changes.
Change streams work through a tailable cursor over the oplog: the application opens a stream, and each new data change is sent as an event document. This feature is only available in replica sets.
Change streams open the door to event-driven architecture. The most common real cases:
const pipeline = [
{
$match: {
operationType: { $in: ["insert", "update"] },
"fullDocument.status": "paid"
}
}
];
const changeStream = ordersCollection.watch(pipeline);
changeStream.on("change", (event) => {
sendNotification(event.fullDocument);
});The example above only reacts to inserts/updates where the status becomes paid — then sends a notification. Compare that to a polling pattern checking the database every second: change streams save resources and provide near-zero latency.
Note that on update operations, the full document isn't always available in the event. To retrieve the latest document, enable the fullDocument option:
const changeStream = ordersCollection.watch([], {
fullDocument: "updateLookup"
});With "updateLookup", MongoDB includes the current document version in fullDocument every time there's an update — making synchronization easy without an additional query.
Warning
A backup without a restore test isn't a backup — it's a hope. Schedule periodic restore tests (e.g. monthly) in a separate environment to ensure data can really be recovered. Many teams only realize their backups are corrupt after a disaster has happened. Automate backups, but never neglect testing the restore.
Info
Choose your backup strategy based on needs: mongodump for flexibility and portability (you can pick a collection or a filter), filesystem snapshots for speed and consistency on large datasets, and Atlas continuous backup for automatic point-in-time recovery. The best strategy often combines both — snapshots for fast recovery, mongodump for selective recovery.
In episode 18 you put together a data rescue strategy: mongodump/mongorestore for flexible logical backups at the database, collection, or filter level; filesystem snapshots via LVM/ZFS for fast and consistent physical backups; point-in-time restore in Atlas for precise rewinding; and change streams to listen to data changes in real time — opening event-driven architecture like notifications, cache invalidation, and sync to search engines.
Key takeaways:
mongodump for flexible logical backups; snapshots for large physical backups.In the next episode, episode 19, we keep the system healthy: Monitoring, Maintenance & Troubleshooting. You'll check health with db.serverStatus, db.currentOp, mongostat, and mongotop, monitor via Prometheus and Grafana, perform maintenance like compact and reIndex, and handle common issues like slow queries, memory pressure, and replication lag. See you in episode 19!