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.

One backup written to five locations and five ways of losing the data: a destructive command run with the access the application already has destroyed the database and four of the five backups, leaving only the copy the database could not reach, and every surviving copy was restored and its five hundred rows counted

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.

Video: We Analyzed 130,000 Vibe Coder Posts. These Are the Problems That Actually Hurt.
Watch it instead We Analyzed 130,000 Vibe Coder Posts. These Are the Problems That Actually Hurt.
From the Back4app channel. This guide is the long version of its second position; the countdown itself is in the companion post. Open on YouTube →

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

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.

A backup is only a backup with respect to a particular disaster. The question is never “do I have one” — it is “which one is this protecting me from”.

What did the destructive command actually reach?

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

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:

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.

The destructive command, run with the app's own access
4 of 5backup copies destroyed along with the data
→
1 of 5locations that survived all five disasters
500rows restored and counted from every surviving copy
The survivor is byte-for-byte the same archive. The only difference is that the destroying process had no route to it. Identical across two runs.

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 — five locations, five disasters, and a restore check on every survivor.

Tagsbackupsdata-lossdockervolumesrecoveryvibe-coding

Frequently asked questions

Where should I store backups of my app's database?

Somewhere the thing most likely to destroy your data cannot write. We tested five locations against five disasters: only the copy the database container had no route to survived all of them. The deciding property is not the storage medium or the schedule, it is reachability.

Why did my backups get deleted along with my database?

Because they were somewhere the same command could reach. We ran a destructive filesystem command with the access the application already had: it took the database and four of the five backup copies with it, including one on a separate volume and one in the project folder.

Is a backup in the project folder good enough?

It survives three of our five disasters, which is better than nothing and is the copy most people actually have. It does not survive the project folder being deleted, and it does not survive a destructive command run with the app's access, because that folder is mounted into the app.

Do Docker volumes protect my data?

They protect it from the container being replaced, which happens on every deploy, and that is genuinely worth having. They do not protect it from the volumes being removed, which one command does, and they do not protect it from anything with write access to what is mounted inside.

How do I know my backup actually works?

Restore it and count the rows. Our lab refuses to call any copy a backup until it has been restored into a clean database and the five hundred rows counted, because a file that has never been restored is a file rather than a backup.

Why should testing and production be separate apps?

So that whatever you point an agent at cannot reach real user data. The same property that saves a backup saves a database: the destructive action can only destroy what its credentials can open. Separate apps make that boundary a configuration rather than a hope.

Further reading

Reviewed & verified by Back4app Engineering, Editorial review at Back4app

Tested Oct 27, 2026 — Local: Docker 29.4.3 on macOS, arm64 · MongoDB 7, mongodump and mongorestore · Every run rebuilds the whole stack · Back4app, free plan.

Changelog

  • Nov 8, 2026 — The companion repository is not published yet, so the link to it and the button were removed; they come back when it is.
  • Oct 28, 2026 — The companion repository is published, so the button and the inline link to it are back.

More from Back4app Engineering

Containers · error-guide

Why Your App Works Locally and Crashes When You Deploy It [Full Repo]

Backend · report

Why Vibe-Coded Apps Break: 13 Problems From 130,000 Posts, Ranked, With the Fix for Each

Web Deployment · tutorial

How to Undo Changes an AI Coding Assistant Made: What Git Recovers, What the Platform Recovers, What Is Gone