How to Configure MongoDB Atlas Backup User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a mongodb atlas backup user by creating a database identity with read privileges. This role allows your backup job to read collections without changing or deleting data. Many engineering teams start by reusing a broad admin account for scheduled data exports. That shortcut creates risk because a compromised export script can modify or drop production collections. Scoping the account to the exact actions required keeps your cluster safe during automated dumps. How a mongodb atlas bac

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 set up a mongodb atlas backup user by creating a database identity with read privileges. This role allows your backup job to read collections without changing or deleting data. Many engineering teams start by reusing a broad admin account for scheduled data exports. That shortcut creates risk because a compromised export script can modify or drop production collections. Scoping the account to the exact actions required keeps your cluster safe during automated dumps.

How a mongodb atlas backup user works in practice

MongoDB uses role-based authorization to control what an account can do after it logs in. Each role grants specific privilege actions on defined database resources down to the collection level. Notice that MongoDB Atlas database users have different built-in roles than self-hosted deployment users. Still, both models build their permissions from the exact same set of underlying privilege actions.

When you set up a backup account, you want read access without write access. In the standard MongoDB model, the read role grants read access to all non-system collections. It also covers the system JavaScript collection within that specific target database. It works by allowing actions like finding documents, listing collections, and listing indexes. It also allows checking database stats, checking collection stats, and opening a change stream. Crucially, the read role leaves out actions that insert, update, remove, or drop collections.

By contrast, the read and write role includes every read action plus data modification rights. It lets a client insert, update, remove, create collections, manage indexes, and drop collections. A dedicated backup process should never hold those modification rights unless it also runs restores. Separating the export account from the restore account reduces the blast radius of leaked keys.

Where native backup roles fall short during live operations

Native database roles do a good job of deciding which account can log in. They also draw a clear line between reading data and mutating data across your databases. Still, role definitions apply to whole collections or entire databases once a session starts. A role cannot inspect individual queries in flight or filter sensitive fields out of results.

When a backup job or an engineer uses a read role, every field comes back. If a collection holds emails, phone numbers, card numbers, or national IDs, exports include them. The database checks that the user has the find action on the collection and returns everything. You also have to manage static secrets or client certificates on every host running backups.

User Provisioning (SCIM) + MongoDB Authentication & Authorization: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Rotating those stored keys across multiple scheduled runners takes manual work and careful timing. If an engineer copies a backup credential to debug a slow query, audit logs blur. Every query shows up under the shared backup account instead of the person running it. Teams need a way to tie every command to a real user identity in flight. They also need field-level masking that rewrites matched fields in results during routine data checks.

Check MongoDB commands and documents on the wire

MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.

Frequently asked questions

What is the difference between read and readWrite roles for backups?

The read role lets a user find documents and list collections or indexes without changing data. The read and write role adds actions that insert, update, remove, and drop collections. Use a read-only role for routine exports so the backup script cannot alter production records.

Can I scope a MongoDB role to a single collection?

Yes, MongoDB roles grant privileges on defined resources down to the collection level of granularity. You can restrict an export account so it only reads the specific collections you select. This prevents a single backup task from pulling unrelated data from other collections in the database.

Do MongoDB Atlas built-in roles match self-hosted MongoDB roles?

MongoDB Atlas database users have different built-in roles than users on self-hosted MongoDB deployments. Still, both sets of roles are built from the same underlying privilege actions in MongoDB. You still control access by combining specific read or admin actions on target database resources.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

Teams test new role rules in staging first. Clear owner lists speed up each audit. Small role scopes cut down on risk. Regular log checks catch drift right away.

The query runs. The emails stay hidden.