MongoDB Backup Breaks: Analysis Through Percona Backup for MongoDB
Most often, MongoDB backup breaks silently: the copy is taken on schedule, reports are green, files are in place — but when a node fails, recovery hits replica desynchronization. The oplog on replica set members has diverged, and the same snapshot describes different data states.
Percona Backup for MongoDB addresses this by fixing a consistent point on each replica set node, from which changes can be replayed to the desired moment.
Node failure during backup is the second typical scenario. A secondary node drops in the middle of a backup, the task remains incomplete, and the next run starts from scratch: instead of one whole copy, you get a torn chain where some points are simply missing.
Worse, if the exact node from which the backup was taken drops, the gap is discovered only during recovery.
The backup window almost always overlaps with peak load.
Taking a copy competes for disk I/O, write response latency grows, and the window itself stretches; at the same time, the oplog window on a loaded replica set is measured in hours, and recovery to "yesterday plus five minutes" may be unreachable.
We break down how this is addressed: where to place the agent, how to distribute roles between nodes, which backup mode to choose, and how to verify that the copy actually restores on a separate test environment.
What Changes After Implementation: Downtime Window and Failure Class
Before implementation, the scheme usually looks like this: a copy is taken on a schedule once a day, stored in object storage, and only the fact of its appearance is monitored.
Until a failure occurs, everything looks working — but during an incident, recovery stretches to hours, and the service is unavailable the whole time. The recovery point objective is tied to the nightly run: the entire volume of changes accumulated over a day is lost.
Percona Backup for MongoDB changes both values. The continuous oplog is stored separately from the full copy, so the recovery point objective shifts to minutes before the failure rather than to the last schedule.
Recovery proceeds by directly restoring the copy together with the oplog — without intermediate dumps and manual assembly, so recovery time is reduced severalfold and no longer depends on who is on duty.
Backup verification becomes a regular procedure, not a one-time action. The full copy is automatically restored on a separate environment, backup integrity and checksum matches are verified — the share of verified backups reaches all runs. A non-working copy is visible in advance, not at the moment of an accident.
The failure class "the copy exists but won't restore" is closed precisely at this step. Downtime due to failure is no longer measured in hours: recovery becomes a predictable operation with a known sequence of actions and estimable time. The recovery point can be set manually — for example, one minute before a dangerous data change.
Logical, Physical, and Streaming Backup: What to Choose
The backup mode is chosen not on the principle of "better or worse," but by workload profile: dataset size, acceptable recovery window, and schema change frequency.
Logical backup reads collections with queries and stores documents in a portable format — the archive restores on another version and allows individual collections to be restored. The price is linear growth of backup time with volume and noticeable load on the production server.
Physical backup copies data files: it runs several times faster and almost does not interfere with query processing, and recovery is laying out ready files. The limitation is binding to the version and storage configuration.
Incremental backup continues from a full snapshot and stores only changed blocks — the daily archive volume drops severalfold. Streaming oplog writes reduce the recovery point to seconds but do not replace a full snapshot.
In Percona Backup for MongoDB, all four modes are enabled with one set of commands, and they can be combined in a single schedule:
| Option | When it fits | Limitations |
|---|---|---|
| Logical backup | Medium datasets, migration between versions, selective collection recovery | Time grows with volume, server load |
| Physical full | Large datasets, short backup window | Binding to version, archive is overwritten entirely |
| Incremental backup | Large databases with daily backups | Requires a base full snapshot and chain |
| Streaming oplog | Point-in-time recovery | Separate storage, does not replace a full snapshot |
Implementation Procedure: From Audit to Handover of Runbooks
Work proceeds in iterations: first we capture what is already protected, then design the scheme, and only then automate. A snapshot schedule without a clear recovery point gives only an illusion of protection — copies exist, but there is nothing to restore the cluster from.
- Backup audit. We collect the current state: what takes backups, where they are stored, who is responsible, when they were last verified. We separately review the failure log — usually there is a job that has been failing silently for months.
- Recovery requirements. We record the acceptable data loss and target recovery time, and whether point-in-time recovery to a specific moment is needed. This determines the composition of backups and the retention depth of oplogs.
- Backup storage scheme. We choose storage remote from production, lay out full and incremental snapshots, set retention and encryption. Accounts used for backup do not receive rights to modify data.
- Snapshot schedule. We configure Percona Backup for MongoDB: an agent on each node, windows outside peak load, replica priority, failure notifications. Backup should not compete with database writes.
- Test recovery. We restore the copy on a separate environment and measure real time. We verify data completeness, not just the task exit code.
- Handover of runbooks. We provide documentation, roles, and checklists, set up monitoring, and walk through the manual scenario. The customer's engineers must be able to bring up the database without us.
Each stage is closed with a verifiable result, so a failure is visible at the step, not at the moment of an accident.
Artifacts: Configurations, Retention Policies, Runbooks
The Percona Backup for MongoDB setup is handed over not as a working script, but as a set of artifacts by which the on-call shift and the next engineer can act without the person who configured it.
Everything listed remains with the customer in the repository and internal knowledge base, with a change history.
- Backup configurations — agent configuration files, run schedules, compression and encryption parameters, binding to nodes and replica sets.
- Retention policy — how many copies and over what horizon are kept, which series are daily, weekly, and monthly, and by what rule they are deleted.
- Recovery runbook — the on-call procedure: from selecting a recovery point to verifying integrity and starting applications, with time estimates for each step.
- Backup monitoring — checks for "job completed / copy is readable / recovery passes," alerts for a missed run, volume growth, and storage unavailability.
- Access rights to backup storage — separation of write and read roles, separate accounts, encryption keys, and list of authorized persons.
- Infrastructure documentation — topology diagrams with storage placement, node addresses, profile and service names, external dependencies.
- On-call shift instructions — procedure for a job failure, replication break, and storage accident before escalation to support engineers.
Implementation Case Study: Recovery in Minutes Instead of Hours
How It Was Set Up Before
Backups were taken by a custom script: a logical dump went through replica set nodes one by one and stored the result in object storage. No one verified write success — it was assumed that a job without errors meant a usable copy. Recovery was tested once, on an empty environment.
When one of the replicas failed, the nearest copy turned out to be a day old: restoring the node took almost a day of downtime, and the divergence between nodes had to be sorted out manually.
What Was Changed
We moved to Percona Backup for MongoDB: the schedule is set by policies, snapshots are taken consistently across the entire replica set, and the oplog is written continuously — hence point-in-time recovery to any moment.
We set up automated verification as a separate environment: once a day the copy is restored on an isolated environment, integrity checks and document counts in key collections are compared.
| Metric | Before | After |
|---|---|---|
| Node recovery | 4–6 hours manually | 15–20 minutes per runbook |
| Replica failure | downtime up to a day, loss of recent operations | replica set restores without data loss |
| Integrity control | backups were not verified | daily recovery run with report |
Rollback before a release deployment stopped being an event: an engineer takes a point one minute before the change and restores it on the test environment — previously there was neither time nor confidence in the backups.
What to Do If Backup Is Already Set Up with a Custom Script?
A custom script is usually structured the same way: a scheduler runs a dump on schedule, archives are stored on the same node or in a network folder, and recovery was tested once during implementation.
It works for years, but there is a single point of failure — the node goes down along with the backups.
There is no need for a head-on migration. First, Percona Backup for MongoDB is installed alongside and starts taking backups to separate storage, while the previous scripts continue to run on their own schedule.
The parallel mode is maintained for as long as needed for verification — during this time the data has two independent lines of protection and there is no gap in backup coverage.
Compatibility is checked before the first backup: we verify the server version and replica set topology, target storage type, write permissions, and access to encryption keys.
Separately, we make sure that the oplog is enabled and its depth is sufficient for point-in-time recovery — otherwise the continuity of backups remains only on paper.
Next is validation in practice: the copy is restored on a separate environment, the number of documents in control collections and recovery time are compared.
Only after that are the old scripts' schedules disabled, and their archives remain in storage until the end of the retention period, so rollback to any previous point is preserved.
Backup history is not lost: it moves to the standard tool's catalog, where each backup has metadata, status, and verification result. Old file sets live alongside until the end of the retention policy.
Technical Concerns: Logs, Windows, Version Compatibility
Percona Backup for MongoDB reads the oplog, not entire collections, so backup does not compete with application writes.
The stream is taken from a secondary node of the replica set: the primary continues serving requests, and reading the oplog only briefly raises disk load on the replica.
A separate maintenance window for backup is not needed — application input does not stop, and replica lag returns to normal immediately after the pass.
A window is required on the reverse step, during recovery. Point-in-time restore replays the oplog on top of the base copy, so the cluster is taken out of write mode for this time and the work is planned as a runbook operation.
Backup storage is chosen based on the task: local volume, network file system, or object storage — switching between them is set by profile, without reworking the backup rules themselves.
Will a backup taken on an old version restore on a new one?
Compatibility is one-way: a copy from an older major branch can be restored on a newer server; the reverse transition is not supported — the metadata in backup storage is written by the version that took the backup.
Before an upgrade, we take a fresh snapshot already with the new version and delete the previous one only after successful verification.
What happens to backup if a replica lags or a node drops?
The backup restarts on another available node in the set, and a gap is recorded in the backup log — it shows for which interval the recovery point is unavailable. Integrity verification after each pass catches a break before it turns into an incomplete copy.
Let's Discuss the Task: What Is Needed for an Estimate and Work Plan
To come back with an estimate and work plan, rather than general statements, we need a minimum of inputs about your MongoDB installation. They determine the scope of stages, the order of work, and which checks we will ask you to perform before starting.
- Deployment scheme: number of nodes in the replica set, whether sharding is used, how roles are distributed, and where arbiters are located.
- Current backup method and what is unsatisfactory about it: execution time, backup size, schedule failures, whether there have been failed recoveries.
- Target metrics: to what point in time data recovery is acceptable and how quickly the system must return to operation.
- Storage for backups: S3-compatible, local, or mixed; retention policy and procedure for deleting outdated copies.
- Access requirements: who runs backups, who is authorized to restore, whether separate accounts are needed for automation.
- Environment constraints: maintenance windows, network limits, current database size and growth rate.
- Existing runbooks and operational documentation — we will improve them rather than start from scratch.
Based on these inputs, we come back with a task estimate and work plan: stages, timelines, control points, and responsibility distribution.
A separate block is the handover of runbooks — schedules and storage profiles for Percona Backup for MongoDB, the procedure for testing recovery on a test environment, and the on-call shift actions in case of failure. Describe the task — we will come back with an estimate and plan.







