Backup, restore and operational tooling

Pick a backup method from your recovery target rather than from convenience, restore into a scratch namespace first, and monitor the signals that predict trouble.

The backup methods

MethodRecovery pointNotes
mongodump / mongorestoreUp to the dumpLogical and portable; slow to restore at scale
Filesystem or volume snapshotUp to the snapshotFast, but needs a consistent stop or a journal flush
Atlas continuous backupSeconds, with the oplogRestores to an arbitrary point inside the window
Delayed replica memberA fixed lag behindA live copy you can promote without a restore step
Oplog replay after a dumpJust before the eventOnly as far back as the retained oplog
mongodump --uri "mongodb+srv://user:[email protected]/shop" \
  --out /backups/2026-09-18 --gzip --oplog

mongorestore --uri "mongodb://localhost:27017" \
  --gzip --oplogReplay --drop /backups/2026-09-18

# single-archive form, easier to move and encrypt
mongodump --uri "$URI" --archive=shop.archive --gzip

Restoring without surprises

  1. Restore into a scratch namespace with --nsFrom and --nsTo, never over the live database.
  2. Compare counts and an aggregate checksum on a few important collections against the source.
  3. Run the application against the restored copy and confirm the queries it depends on work.
  4. Only then promote it, and record how long the whole exercise took — that number is your real recovery time.
db.orders.countDocuments({})

db.orders.aggregate([
  { $group: { _id: null, total: { $sum: "$total" }, orders: { $sum: 1 } } }
])
  • mongorestore rebuilds indexes by default; --noIndexRestore is faster for a bulk load you intend to index afterwards.
  • Restoring a single collection is often all you need after a bad script, and it is far cheaper than a full restore.
  • A restore is a load test. It also tells you whether the indexes and the document count match what the application expects.

Monitoring and the operational basics

SignalWhy it matters
connections in serverStatusApproaching the limit means requests queue and then time out
Replication lagRead preference correctness and failover readiness
Oplog windowHow far a consumer or a backup can fall behind
db.currentOp()Long-running operations, and the indexes they are missing
Disk free spaceWiredTiger needs room to write new journals and to compact
Cache eviction and page faultsThe working set no longer fits in RAM
⚠️
A backup becomes a backup only once it has been restored. Schedule the restore drill, restore into a scratch namespace, and record the elapsed time. During an incident the number you need is recovery time, not backup size.

FAQ

How often should I back up?
Work backwards from the recovery point objective: how much data can the business afford to lose? Continuous oplog-based backup gives seconds, a nightly dump gives up to a day. The schedule follows from that answer rather than from what is convenient.
Is a delayed replica a backup?
It is a useful second line of defence against an accidental delete, because you can promote it after the damage has replicated. It is not a backup: it lives on the same platform, shares the same credentials, and cannot restore one collection to a chosen point in time.

Replica sets, failover and read preferences Setting up MongoDB: Atlas, local install and mongosh

Last refreshed 2026-09-18.