# MongoDB Atlas

Back up a MongoDB Atlas cluster from SimpleBackups with an SRV connection string, an IP access list entry, and a read-only database user.

MongoDB Atlas is MongoDB's managed database. SimpleBackups reaches it over the network and dumps it with `mongodump`, the same way it backs up any other MongoDB host. Atlas refuses that connection until the project's IP access list includes SimpleBackups and the connection string uses a user that can read the data. This page is that setup. Scheduling, storage, and retention are the same as any other [MongoDB backup](https://simplebackups.com/docs/database-backup/mongodb-backup/overview).

## Use the SRV connection string

Atlas publishes the cluster as a DNS seed list. The connection string starts with `mongodb+srv://`. A `mongodb://` string with one host and port does not match that address, so the connection fails.

1. In Atlas, open the cluster and click **Connect**.
2. Choose **Drivers**.
3. Copy the connection string. It looks like this:

```plain
mongodb+srv://backup_user:password@cluster0.example.mongodb.net/myDatabase?retryWrites=true&w=majority
```

4. Replace `password` with the database user's password. Put the database you want to back up before the `?`. Leave the database name out when the user should back up every database it can read.
5. In SimpleBackups, create a MongoDB backup, open the **Connection String** tab, and paste the string.

**Encode reserved characters in the password:**
A raw `@`, `:`, `/`, or `#` in the password splits the connection string. URL-encode those characters before you paste it.

## Allow SimpleBackups in Network Access

Atlas drops connections from addresses that are not on the project access list. Add the [SimpleBackups IP addresses](https://simplebackups.com/docs/help-tips-and-troubleshooting/connecting-a-server/simplebackups-ip-addresses-firewall) before you validate the backup.

1. In Atlas, open **Network Access**.
2. Click **Add IP Address**.
3. Add each address from the SimpleBackups list. Add the IPv6 addresses as well when the cluster accepts them.

The backup form shows the same list under **Behind a firewall?** when the backup runs on SimpleBackups.

## Create a read-only backup user

Create a user that exists only for backups. Do not reuse an Atlas admin account.

1. In Atlas, open **Database Access**.
2. Click **Add New Database User**.
3. Choose **Password** and set a password.
4. Under **Database User Privileges**, add one built-in role on `admin`:
   - `backup`, the role `mongodump` is built for.
   - `readAnyDatabase`, when the backup only needs to read your own databases.

Atlas rejects `db.createUser()`. Create the user on the Database Access page, then put that user and password in the connection string.

**Keep the backup user read-only:**
`backup` and `readAnyDatabase` do not grant write access to your data. Do not assign `atlasAdmin` or `readWriteAnyDatabase` to this user.

## Related

- [MongoDB Backup](https://simplebackups.com/docs/database-backup/mongodb-backup/overview): How a MongoDB backup is taken, stored, and restored.

- [SimpleBackups IP addresses (firewall)](https://simplebackups.com/docs/help-tips-and-troubleshooting/connecting-a-server/simplebackups-ip-addresses-firewall): The addresses to add on the Atlas Network Access page.
