How to back up a Postgres database for a small SaaS
To back up a Postgres database for a small SaaS, run pg_dump on a schedule, write the file to storage outside the database server, keep several days of copies, and restore one into a scratch database to prove it works. A backup you have never restored is a guess.
This guide gives that routine as numbered steps, then explains what managed hosts such as Supabase and Neon already do, so you know what you still have to add. The vendor details were read on 22 November 2026.
What a backup needs to survive
Before picking a tool, name the failures you are protecting against. A small SaaS usually faces three:
- You delete or overwrite data by mistake, for example a migration that drops a column or an
UPDATEwithout aWHERE. - The database server or its disk is lost.
- The account that holds the database is locked, deleted or compromised.
A copy on the same disk covers none of these well. The third is why the copy has to live somewhere your database login cannot reach.
Step by step: a nightly dump you can restore
The PostgreSQL manual describes the SQL dump method: pg_dump generates a file with SQL commands that, when fed back to the server, recreate the database in the state it was in at the time of the dump. It does not block other operations while it works, apart from operations that need an exclusive lock, such as most forms of ALTER TABLE. That makes it safe to run on a live database.
- Create a read-only database user for backups, so the job cannot change data.
- Dump in the custom format:
pg_dump -Fc "$DATABASE_URL" > app-$(date +%F).dump. The manual notes the custom format compresses the output (when built with zlib) and lets you restore tables selectively. - Copy the file to object storage or another machine, and check the upload succeeded before the job deletes the local file.
- Keep a rolling set. Seven daily copies and a few older weekly ones is a sensible start for a small product. The right number depends on how long you could go before noticing bad data.
- Schedule it with cron, a GitHub Actions schedule, or your host's job runner, and make the job send you a message on failure.
- Restore a copy into an empty scratch database:
pg_restore -d scratch app-2026-11-22.dump. Open the app against it and check a few real rows.
Two limits from the manual are worth knowing. pg_dump dumps one database at a time and does not include roles or tablespaces, which are cluster-wide. If you need those, pg_dumpall covers the whole cluster. And a plain-text dump is restored with psql, while non-text dumps need pg_restore, so note which format your job uses in the runbook.
What managed hosts already do
If you run Postgres on a managed host, part of this is done for you. Read the plan details before you rely on them.
| Host | What the docs say | What you still add |
|---|---|---|
| Supabase | Daily backups on Pro, Team and Enterprise: the last 7, 14 and 30 days respectively. Point-in-time recovery is an add-on for those plans. | Free-plan projects are told to export regularly with the CLI db dump command and keep off-site copies. Backups do not include Storage API objects, only their metadata. |
| Neon | Instant restore (point-in-time) reverts a root branch to an earlier state inside your plan's history window, and creates a backup branch before it overwrites. | Check the window for your plan on the restore page, and keep a dump somewhere outside the account. |
| Single VM you run yourself | Nothing. | Everything in the steps above. |
The Supabase details come from its backups documentation. One point there matters for file uploads: database backups do not contain files you store through the Storage API, so a restore brings back the rows that point to files but not the files. If your app stores user uploads, back those up separately.
A host snapshot and your own dump also protect against different things. A snapshot restores fast but lives in the vendor's account. A dump is slower but is yours, and you can load it into any Postgres.
A restore drill that takes ten minutes
Put a recurring calendar reminder for the first of each month and run this:
- Download the newest dump from your off-site storage, not from the server.
- Create a scratch database and restore into it.
- Run your app locally or on a staging environment against it.
- Check the newest row in your busiest table and compare its timestamp with what you expect.
- Write down how long the restore took. That number is your real recovery time.
If any step fails, you found the problem on a quiet Monday instead of during an outage.
Common mistakes
- Storing the only copy on the database server. A disk failure then takes both.
- Dumping with the admin user and leaving its credentials in the job logs. Use the read-only user.
- Never alerting on failure. A job that silently stopped three weeks ago looks the same as one that works. Pair it with the checks in error monitoring for an indie SaaS or a heartbeat from one of the free uptime monitoring tools.
- Forgetting secrets and files. Environment variables, uploaded files and object storage are not in a database dump.
Who should pick what
- On a managed host with point-in-time recovery: keep it on, and add a monthly dump to storage in a different account.
- On a free managed plan: schedule the dump yourself from day one, since the plan may not include backups at all.
- On a single VM: use the steps above and keep the VM setup in a script, as in deploying Next.js on a single VM with Docker.
Frequently asked questions
How often should I back up a small SaaS database?
Daily is a common default. Pick the interval from how much data you could afford to lose: if losing a day of signups would hurt, add point-in-time recovery from your host, or dump more often.
Does pg_dump lock my database?
Not for normal reads and writes. The PostgreSQL manual says it does not block other operations, except those that need an exclusive lock, such as most forms of ALTER TABLE. Avoid running migrations while a dump is in progress.
Is a Supabase backup enough on its own?
For the database rows on a paid plan, it covers a lot. It does not include Storage objects, and it sits in the same vendor account as the project, so an off-site copy is still sensible.
What is the difference between a dump and point-in-time recovery?
A dump is a file of the database at one moment. Point-in-time recovery lets a host rewind the database to a chosen moment inside a retention window, which suits an accident you notice an hour later.