# 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.

By Waseem Anjum · Published 2026-11-22 · https://fabwaseem.com/blog/coolify-postgres-backup-cloudflare-r2

> **TL;DR:** Coolify can run scheduled pg_dump backups of a Postgres database and upload them to any S3-compatible storage, including Cloudflare R2. Create an R2 bucket and token, add it under Storage, then enable S3 on the database's backup schedule and test a restore into a throwaway database.

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](https://fabwaseem.com/blog/self-host-nextjs-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](https://coolify.io/docs/databases/backups).

For Postgres the output depends on the scope you pick:

- **Specific databases:** `pg_dump` in 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](https://coolify.io/self-host-postgres-with-backups) notes.

![Diagram showing a Postgres dump written to the local Coolify backups folder, uploaded to a Cloudflare R2 bucket, and restored through Import Backup](https://res.cloudinary.com/wasicloudinary/image/upload/v1795321891/fabwaseem/projects/fcnp2dyke3oh1jmkqknq.jpg)

## 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?

1. In the Cloudflare dashboard, create an R2 bucket, for example `db-backups`.
2. Create an R2 API token with **Object Read & Write** permission. You can scope it to just that bucket.
3. 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](https://coolify.io/docs/knowledge-base/s3/r2).

## How do I add R2 as S3 storage in Coolify?

In the Coolify sidebar open **Storage**, choose **New storage**, and fill in:

| Field | Value |
|---|---|
| Bucket name | your bucket, for example `db-backups` |
| Protocol | `https` |
| Host | `<ACCOUNT_ID>.r2.cloudflarestorage.com`, without `https://` |
| Port and Path | leave empty for the standard endpoint |
| Region | leave the default; R2 treats an empty value or `us-east-1` as its `auto` region |
| Access key and secret | the token values from the previous step |

Select **Validate Connection & Continue**. Coolify checks the connection by listing the bucket's objects.

## How do I schedule the Postgres backup?

1. Open the Postgres database in Coolify and select **Backups**.
2. Click **+ Add** next to **Database backups**.
3. Enter a cron expression or a named frequency, then click **Add schedule**.

Coolify accepts these named schedules:

| Name | Cron |
|---|---|
| `every_minute` | `* * * * *` |
| `hourly` | `0 * * * *` |
| `daily` | `0 0 * * *` |
| `weekly` | `0 0 * * 0` |
| `monthly` | `0 0 1 * *` |
| `yearly` | `0 0 1 1 *` |

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.

![Checklist of the Coolify storage form fields and backup schedule settings for a Cloudflare R2 backup](https://res.cloudinary.com/wasicloudinary/image/upload/v1795321893/fabwaseem/projects/xp2l3a0hgmg0wg1uslq8.jpg)

## 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.

1. Create a throwaway Postgres resource.
2. Open **Import Backup** on it. The file can come from your computer, an absolute server path, or S3.
3. Coolify picks `pg_restore` or `psql` and shows the command. It accepts SQL, custom, tar and all-database dumps, compressed as gzip, bz2, xz or zip.
4. 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](https://www.postgresql.org/docs/current/app-pgrestore.html) 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](https://fabwaseem.com/blog/postgresql-14-end-of-life-upgrade). To expose a self-hosted stack safely, see [Cloudflare Tunnel with Docker Compose](https://fabwaseem.com/blog/cloudflare-tunnel-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

### How do I back up a Postgres database in Coolify?

Open the database, select Backups, click + Add next to Database backups, enter a cron expression or a named frequency such as daily, and add the schedule. Coolify then dumps the database on that schedule and stores the files under /data/coolify/backups on the server.

### Can Coolify back up Postgres to Cloudflare R2?

Yes. R2 is S3-compatible, so you add it under Storage > New storage with the R2 endpoint host and an API token, then enable S3 on the backup schedule and pick the R2 storage.

### What format does a Coolify Postgres backup use?

For selected databases Coolify runs pg_dump in custom format. When All databases is selected it uses pg_dumpall and gzips the result.

### How do I restore a Coolify Postgres backup?

Open Import Backup on the running database and choose the file from your computer, an absolute server path or S3. Coolify picks pg_restore or psql and shows the command it will run. Stop application writes and back up the target first.

### Does Coolify support point-in-time recovery for Postgres?

No. Scheduled backups are dumps, so you can restore to the moment a dump ran. Point-in-time recovery needs continuous WAL archiving, which is a separate setup.

### Does Coolify back up Redis too?

No. According to the Coolify docs, the supported databases are PostgreSQL, MySQL, MariaDB, MongoDB, ClickHouse and SQLite. Redis, Dragonfly and KeyDB are not supported.
