How to Fix MongoDB Error 268 (CannotBackup)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mongodb error 268 when the database cannot run a backup job. You fix it by checking storage states, node health, and user role rules. The official error name for code 268 is CannotBackup. When this failure happens, your data snapshots stop working right away. Teams must find the root cause fast to keep data safe. What causes mongodb error 268 in your cluster The CannotBackup error points to a problem during a backup operation. Often, the storage engine cannot lock or read the files i

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mongodb error 268 when the database cannot run a backup job. You fix it by checking storage states, node health, and user role rules.

The official error name for code 268 is CannotBackup. When this failure happens, your data snapshots stop working right away. Teams must find the root cause fast to keep data safe.

What causes mongodb error 268 in your cluster

The CannotBackup error points to a problem during a backup operation. Often, the storage engine cannot lock or read the files it needs. Disk space might be full on the target host or storage volume. Network drops between the cluster node and the backup target also cause this.

Node state matters a lot during a backup job. A replica set member might be in a state that blocks backups. If a node is still starting up, it cannot serve a backup request. If a node is recovering, the database engine will also reject the task.

Permission issues can trigger backup failures too. MongoDB grants access through role-based rules. A role gives privileges to run sets of actions on specific resources. If your backup tool lacks the right role, the backup job will fail.

Note that self-hosted deployments and cloud clusters use different built-in roles. Still, both build their roles from the same set of privilege actions. A role applies to the database where you define it. It can grant access down to a single collection.

How to diagnose and fix the failure in production

Start by reading the database server logs from the time of the crash. Look for disk errors, missing paths, or storage engine alerts near code 268. Check free disk space on both the database node and backup storage.

MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Next, check the health of your replica set members. Make sure the node you want to back up is healthy and online. If one node is busy or recovering, point the backup job elsewhere. Routing the backup to a healthy secondary node protects primary app traffic.

Review the database user account that runs the backup agent. Do not grant full admin rights just to make a backup work. Keep permissions tight to protect your production data.

For basic data reads, the built-in read role grants access to non-system collections. It allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It blocks write actions like insert, update, remove, or dropCollection. If your backup method needs extra system access, pick only the required role.

How to prevent backup failures and secure data

Good monitoring catches disk and node issues before code 268 appears. Set alerts for high disk usage and replica set state changes. Test your backup jobs on a staging cluster after any system update.

Protect sensitive data when teams check backup logs or query collections. Masking tools can rewrite matched fields like emails or phone numbers in results. This also works well for card numbers and national IDs during live checks. Teams can fix database errors while keeping private records safe.

Inspect MongoDB wire traffic in flight

Built-in MongoDB roles govern collection access at setup time. They cannot score command risk per call or mask sensitive document values on the fly. By design, hoop.dev sits inline in the MongoDB protocol next to your server as a sidecar for your MongoDB. On every production command from mongosh, drivers, or AI agents, hoop.dev decides whether to pass, mask, block, or hold it for human review.

First, hoop.dev guardrails block bad deletes, drops, and write pipelines or hold them for approval. Next, hoop.dev data masking rewrites sensitive values in returned documents in memory and logs each decision. Explore the repo on GitHub.

Frequently asked questions

What is the official name for mongodb error 268?

The official name for error code 268 in MongoDB is CannotBackup. The database returns this code when it cannot start or finish a backup.

Can I use the readWrite role for a read-only backup user?

No, you should not use the readWrite role for a read-only backup user. That role allows insert, update, remove, and dropCollection actions, which adds risk.

Does error 268 mean my database data is corrupt?

Not always, as this error often comes from disk space or state limits. Check your server logs to see why the engine blocked the backup job.

The query runs. The emails stay hidden.