Documentation

Backup Orchestration

Backup Orchestration

Backup Orchestration coordinates consistent MongoDB backups across a replica set: pick a healthy secondary, take an fsyncLock, let a system-level snapshot capture the on-disk state, and release the lock. VisuaLeaf drives the full lifecycle from the UI, tracks progress, and schedules an optional rolling-compact as a post-backup step to reclaim disk space.

Quick Start

  1. Open Administration → Backups.
  2. Select a replica set from your Fleet.
  3. Click New backup plan and confirm the recommended target secondary.
  4. Kick off the plan. Progress and lock state stream live.
  5. Optionally enable Rolling compact to run after the backup finishes.

Why fsyncLock Matters

A file-level snapshot of MongoDB data files is only useful if the files are consistent. db.fsyncLock() flushes pending writes to disk and blocks further writes until unlocked, giving your snapshot tool a stable on-disk image. Without fsyncLock — or an equivalent WiredTiger checkpoint guarantee — a snapshot can capture a torn state that fails to recover cleanly.

Warning: Never Run on PRIMARY Without Staggering

Locking the primary blocks all writes to the replica set until the lock is released. VisuaLeaf defaults to a healthy SECONDARY and will refuse a primary target unless you explicitly override with an incident checkbox. If you must lock the primary — for example, a single-node deployment — schedule it during a maintenance window and expect application-visible write pauses.

For a replica set with multiple secondaries, stagger backups so no two members are locked simultaneously. VisuaLeaf's scheduler enforces this per replica set.

Backup-Plan Dialog

Clicking New backup plan opens a step-by-step dialog:

  1. Target selection: VisuaLeaf lists eligible SECONDARY members ranked by health (low lag, no active election, no ongoing index build).
  2. Snapshot integration: pick from configured system-snapshot integrations (see below), or select Manual to run your own tooling between lock and unlock.
  3. Post-backup actions: optionally enable rolling compact, oplog checkpoint recording, or a custom webhook.
  4. Schedule: run now or on a cron expression (e.g. 0 3 * * *).
  5. Review: the dialog shows the exact command sequence before executing.

Target-Secondary Selection

VisuaLeaf scores each candidate secondary and picks the safest by default:

Signal Impact on ranking
Oplog lag < 5s Required. Higher-lag members are excluded.
Hidden secondary Preferred — no client traffic to worry about.
Priority = 0 Preferred — ineligible for primary election.
Active index build Excluded. Backup would capture an in-progress index.
Already-locked Excluded to prevent overlapping backups.

Progress Tracking

Once a plan starts, the panel streams live state:

  • Pre-flight checks: confirm target state, verify lock is not already held.
  • Lock acquired: timestamp of the fsyncLock call, from which point the snapshot is consistent.
  • Snapshot in progress: integration-reported progress (percent, bytes copied, throughput).
  • Lock released: timestamp of the fsyncUnlock call.
  • Post-actions: rolling-compact progress if enabled.
  • Completion: total duration, lock hold-time, snapshot size.

Rolling-Compact Scheduling

After a successful backup, Rolling compact optionally runs compact on the target secondary to reclaim WiredTiger free-space fragmentation. Because the member is already at a low-traffic state and its snapshot has been captured, this is the safest window to compact. VisuaLeaf can then step-down and roll to the next secondary on subsequent runs so every member gets compacted over time.

Integration with System Snapshotting

Backup Orchestration doesn't ship storage — it wraps the tool you already use. Configured integrations trigger the snapshot between lock and unlock:

  • LVM snapshot — for on-prem or self-managed hosts.
  • AWS EBS snapshot — via configured IAM role, tagged with the backup plan ID.
  • GCP persistent-disk snapshot — via configured service account.
  • Azure managed-disk snapshot — via configured service principal.
  • ZFS / Btrfs snapshot — for filesystems that support atomic snapshots natively.
  • Manual — VisuaLeaf just handles the lock lifecycle; your external tool does the copy.

The fsyncLock Lifecycle

Understanding the lock lifecycle is essential for safe operation:

  1. Backup plan starts. VisuaLeaf opens a dedicated session against the target secondary.
  2. db.fsyncLock() is called. All in-flight writes are flushed; new writes on the target are blocked (secondaries reject writes anyway, but oplog application also pauses).
  3. The snapshot tool runs. Oplog lag on this member climbs during the lock — expected.
  4. Snapshot finishes. VisuaLeaf calls db.fsyncUnlock() on the same session that acquired the lock.
  5. The secondary resumes oplog application and catches up.

A dropped socket in step 2–4 can leave the lock held indefinitely — see the recovery section below.

Recovery from a Stuck fsyncLock

Recovering a Stuck Lock

A stuck fsyncLock shows up as: increasing lag on one secondary, the Backups page marking the plan as Stalled, and db.currentOp() on the target showing a long-lived fsyncLockWorker.

To recover:

  1. Confirm no snapshot is still copying. Force-unlocking during a copy corrupts your backup.
  2. Reconnect to the same target secondary — fsyncUnlock is a session-scoped counter.
  3. Call db.fsyncUnlock() once per outstanding lock. VisuaLeaf's Force unlock button loops this until the reported lockCount is zero.
  4. If the process is truly hung, restarting mongod on the target secondary is safe — it will resync from the primary on startup.
  5. Mark the plan as failed and start a fresh one.

Pro Tips

  1. Prefer hidden secondaries: they take no client reads, so locking them affects no application traffic.
  2. Retain oplog longer than your longest backup: otherwise the target secondary needs a full resync after unlock.
  3. Snapshot the journal too: if your snapshot excludes the journal directory, your backup is worthless.
  4. Test restores regularly: a backup you have not restored is a hope, not a plan.
  5. Combine with Oplog Browser: capture the oplog ts at lock time to support point-in-time recovery.

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial