# Where to Keep Database Backups So the Command That Deletes Your Data Can't Reach Them

Agents have deleted production databases. In the cases people write up afterwards, the painful detail is rarely the deletion — it is that the backups were somewhere the same command could reach.

URL: https://www.back4app.com/blog/database-backups-that-survive-deletion
Published: 2026-11-13 · Tested: 2026-10-27
Tested on: Local: Docker 29.4.3 on macOS, arm64 · MongoDB 7, mongodump and mongorestore · Every run rebuilds the whole stack · Back4app, free plan
Publisher: Back4app Engineering

Agents have deleted production databases. One documented case took nine seconds, and the part people remember is not the deletion — it is the sentence that follows, about the backups having been on the same drive.

About a third of people in the study behind our countdown reported real damage from losing data. That is the highest rate of anything on the list, and it is not mostly carelessness. It is a property of where the backup was.

So we wrote one dump to five places that differ in exactly one way — what can reach them — and then lost the data five different ways.

## Watch it instead

Losing your data is number 2 in our countdown of what actually goes wrong for people building with AI.

## Which backups survived what?

Not the ones you would hope, and the pattern is sharper than "keep backups":

![Five backup locations tested against five disasters: a destructive command run with the application's own access destroys four of the five, leaving only the copy the database container cannot reach, while a dump in the project folder survives three of the five](/blog/blog-assets/can-your-backup-survive-this/survival-matrix.png)

Every "ok" in that table is a real restore. The archive is loaded into a clean database and its five hundred rows are counted, because a file nobody has ever restored is a file, not a backup.

## What did the destructive command actually reach?

Everything mounted into the thing running it, which is more than people picture:

```text
AN AGENT RUNS rm -rf WITH THE ACCESS THE APP HAS

    1. inside the container              gone
    2. in the data volume                gone
    3. another volume, same host         gone
    4. in the project folder             gone
    5. where the database cannot reach   restored 500 rows
```

The copy on a *separate volume* went too. So did the one in the project folder. Neither is a weak choice in general — they just happened to be visible from inside the same container as the data.

The survivor is not a better copy. It is byte-for-byte the same archive. The only difference is that the process doing the damage had no path to it.

## What about an ordinary deploy?

Less dramatic, and still enough to take a backup with it:

```text
THE CONTAINER IS REPLACED  (every deploy)

    1. inside the container              gone
    2. in the data volume                restored 500 rows
```

A deploy does not restart your container, it replaces it, and replacement discards the writable layer. Anything written inside — logs, uploads, a dump someone put in `/tmp` — goes with it.

Volumes fix that one case, which is worth having. They do not survive `docker compose down -v`, which is one command and a tempting thing to suggest when something is stuck.

## Does the project folder count?

It is the copy most people actually have, and it does better than its reputation — it survived three of our five disasters. It is a real improvement over nothing.

It fails in exactly two places. The project folder being deleted, which is the obvious one. And a destructive command run with the app's access, because that folder is mounted into the app so that the app can write to it.

That second failure is the whole problem in miniature. The copy has to be writable by something in order to be made, and whatever can write it can usually unwrite it.

## So what is the rule?

Ask one question of your backup: **can the thing most likely to destroy my data also reach this copy?** If the answer is yes, you have a second copy of your data rather than a backup of it.

In practice that means different credentials, not just a different folder. A dump written by a job the application cannot invoke, to a place the application cannot open, is protected by the same property that saved location 5.

The matching habit is separating testing from production, which is the same rule applied to the agent: whatever you point it at should not hold keys to real user data. Then the worst case is a bad afternoon rather than a bad year.

## What should you do first?

Restore one. Take whatever backup you currently have, load it into an empty database, and count the rows. That single exercise moves a file into the category of backup, and it is the one most people have never done.

Then check the reach. Open the credentials your app uses and ask whether they can write to where the backup lives. If they can, move the backup — not the data.

[The lab is in the repo](https://github.com/templates-back4app/backup-lab) — five locations, five disasters, and a restore check on every survivor.
