MongoDB Tutorial 0/120 lessons ~6 min read Lesson 85

    Backup Strategies

    Backup is the last line of defense against bad code, ransomware and human error.

    Course progress0%
    Focus
    6 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    Backup is the last line of defense against bad code, ransomware and human error. A replica set protects against hardware failure; it does not protect against db.dropDatabase(). Backups are independent, point-in-time copies stored away from the cluster.

    MongoDB Atlas offers continuous cloud backups with point-in-time restore down to the second. Self-hosted teams use mongodump, file-system snapshots, or Ops Manager. Whichever you choose, the rule is the same: untested backups don't exist.

    Understanding the topic

    The four backup strategies — pick at least one:

    • Atlas Continuous Backup — oplog-tailing, PIT restore to any second in the last 7–30 days. Set-and-forget for cloud teams.
    • Atlas Cloud Snapshots — daily/weekly EBS-style snapshots, fastest restore for whole-cluster recovery.
    • mongodump / mongorestore — logical BSON export. Portable, slow on large clusters, excellent for collection-level restores.
    • Filesystem snapshots (LVM, EBS) — fast, requires fsyncLock or journaling. Used by ops teams self-hosting.
    • Ops Manager / Cloud Manager — enterprise on-prem; oplog tailing + scheduled snapshots + PIT.

    Informative example

    Daily backup with mongodump, gzipped and shipped to S3:

    bash
    #!/usr/bin/env bash
    set -euo pipefail
    TS=$(date -u +%Y%m%dT%H%M%SZ)
    mongodump --uri="$MONGO_URI" --archive=/tmp/dump-$TS.gz --gzip --readPreference=secondaryPreferred
    aws s3 cp /tmp/dump-$TS.gz s3://acme-mongo-backups/$TS.gz --storage-class GLACIER_IR
    # 30-day retention, automated lifecycle policy on the bucket
    rm /tmp/dump-$TS.gz

    Real-world use

    Every regulated industry (banking, healthcare, gov) requires daily off-cluster backups with documented RPO/RTO. Most SaaS teams run Atlas continuous + a weekly mongodump to a cold S3 bucket for the "two backup providers" rule.

    Best practices

    • Define and publish your RPO (recoverable point objective) and RTO (recoverable time objective).
    • Run a restore drill monthly — restore to a sandbox and verify checksums.
    • Use secondary reads for mongodump so the primary keeps serving traffic.
    • Encrypt backups at rest and require MFA to download them.

    Common mistakes

    • "We have replication, we're fine" — replication is not backup.
    • Storing backups in the same cloud account as production — one compromised IAM key kills both.
    • Untested backups — the day you need them is the worst day to find out they're corrupt.
    Ready to mark this lesson complete?Track your journey across the entire course.