Coolify Postgres Backup to Cloudflare R2: Setup and Restore
Set up a scheduled Coolify Postgres backup that uploads to Cloudflare R2, keep retention under control, and learn how to restore a dump into a test database before you need it.

On this page
A Coolify Postgres backup is a scheduled pg_dump (or pg_dumpall) run that Coolify handles for you, and the safest place to keep it is off the server, in an S3-compatible bucket such as Cloudflare R2. This guide shows the full setup: create the R2 bucket and token, connect it to Coolify, schedule the dump, set retention, and restore the file into a test database so you know it works.
If you have not deployed anything on Coolify yet, start with how to self-host Next.js with Coolify.
What does a Coolify Postgres backup actually contain?#
Coolify supports scheduled backups for PostgreSQL, MySQL, MariaDB, MongoDB, ClickHouse and SQLite. Redis, Dragonfly and KeyDB are not supported, according to the Coolify backup docs.
For Postgres the output depends on the scope you pick:
- Specific databases:
pg_dumpin custom format. - All databases:
pg_dumpall, gzipped.
Files land in /data/coolify/backups on the server. These are logical dumps, so you can restore to the moment a dump ran. Point-in-time recovery needs continuous WAL archiving, which Coolify's scheduled backups do not provide, as the Coolify Postgres guide notes.

Why store Postgres backups in Cloudflare R2?#
A backup that lives only on the database server disappears with the server. An S3-compatible bucket gives you a second location with its own retention rules. R2 speaks the S3 API, and Cloudflare documents the endpoint as https://<ACCOUNT_ID>.r2.cloudflarestorage.com. Coolify treats it like any other S3 storage, so no extra tooling is needed.
How do I create the R2 bucket and API token?#
- In the Cloudflare dashboard, create an R2 bucket, for example
db-backups. - Create an R2 API token with Object Read & Write permission. You can scope it to just that bucket.
- Save the Access Key ID, Secret Access Key and the S3 endpoint shown on the confirmation page.
These steps follow the Coolify Cloudflare R2 guide.
How do I add R2 as S3 storage in Coolify?#
In the Coolify sidebar open Storage, choose New storage, and fill in:
Select Validate Connection & Continue. Coolify checks the connection by listing the bucket's objects.
How do I schedule the Postgres backup?#
- Open the Postgres database in Coolify and select Backups.
- Click + Add next to Database backups.
- Enter a cron expression or a named frequency, then click Add schedule.
Coolify accepts these named schedules:
The timezone field is read-only and uses the server timezone if set, otherwise the instance timezone. If the database is stopped when the schedule fires, that run is skipped. Coolify recommends a timeout of at least 60 seconds; if you leave it unset the job default is 3600 seconds (one hour).
Under General > Backup schedule you choose All databases or Specific databases and list the ones to back up.
How do I turn on the R2 upload and set retention?#
Open the schedule, go to S3 storage, select your R2 storage under S3 storages, tick Enable S3 and save. Optionally set Local copy to Delete after S3 upload. Coolify removes the local file only after every selected S3 destination succeeds, and an S3 warning means at least one upload failed.
Retention has three limits, each set to 0 for no limit: Backups to keep, Days to keep and Maximum storage (GB). The limits apply independently and the oldest backups go first when any of them is reached. S3 retention is configured separately from local retention, so set both.

How do I check that the backup really worked?#
Click Back up now on the schedule and look for three things: status Success, a file size above zero and a successful upload. Then open the R2 bucket and confirm the object is there. The Coolify docs are direct about the limit of this check: a successful backup only proves that Coolify created a file.
How do I restore a Coolify Postgres backup?#
Restore into a disposable database first.
- Create a throwaway Postgres resource.
- Open Import Backup on it. The file can come from your computer, an absolute server path, or S3.
- Coolify picks
pg_restoreorpsqland shows the command. It accepts SQL, custom, tar and all-database dumps, compressed as gzip, bz2, xz or zip. - Run a few row counts against your biggest tables and compare them with production.
The restore runs in one transaction, and replacing existing objects and keeping owners and privileges are both off by default. If you restore by hand from a downloaded custom-format dump, the pg_restore reference covers options such as --clean, --if-exists and --no-owner.
Before restoring over a live database, stop application writes and take a separate backup of the target first.
What should I watch out for?#
- Deleting a database: the option to delete its backups is off by default. If you leave it off, files stay in
/data/coolify/backups/and in S3, and Coolify no longer prunes them. - Failure alerts: a failed backup notifies on the first failure, then at most once a day, and Coolify never disables a schedule automatically.
- Coolify's own backup: a Coolify instance backup saves settings, not database contents.
- Bigger changes: planning a major Postgres upgrade? Take a fresh dump first and read the PostgreSQL 14 end-of-life upgrade guide. To expose a self-hosted stack safely, see Cloudflare Tunnel with Docker Compose.
Key takeaways#
- A Coolify Postgres backup is a logical dump, not continuous WAL archiving.
- Add R2 under Storage with an Object Read & Write token, then tick Enable S3 on the schedule.
- Set local and S3 retention separately.
- Use Back up now to verify size and upload.
- Restore into a throwaway database and check row counts before you trust the schedule.
Questions
Share this guide



Comments
No comments yet. Questions, corrections and your own results are all welcome.
Be kind and stay on topic. No name needed: leave it blank and you post under an anonymous name that stays yours. Links get
nofollow; spam is removed. Your email is never shown and is only used for reply notifications you ask for. Privacy