---
title: "Deploy Backup Postgres to R2"
description: "Backup Postgres to R2 (or S3) using Railway's Cron"
category: "Automation"
url: https://railway.com/deploy/backup-postgres-to-r2
---

# Deploy Backup Postgres to R2

Backup Postgres to R2 (or S3) using Railway's Cron

**[Deploy Backup Postgres to R2 on Railway](https://railway.com/template/backup-postgres-to-r2)**

- **Creator:** Dylan Anthony's Projects
- **Category:** Automation
- **Total deploys:** 3

## Template content

### rclone-postgres-backup

- **Source:** dbanty/rclone-postgres-backup

## Documentation

# Deploy and Host Backup Postgres to R2 on Railway

This backup job runs a single time, to be scheduled with [Railway's native Cron feature](https://docs.railway.com/reference/cron-jobs). This should save some compute cost over a long-running job (like the official Railway template).

This template was created for [Cloudflare R2](https://developers.cloudflare.com/r2/), but it uses [rclone](https://rclone.org/) under the hood, so it can back up to virtually anywhere with a little tweaking.

## About Hosting Backup Postgres to R2

To set up properly:

1. Configure environment variables for your database &amp; R2 bucket
2. Disable restarts
3. Set a Cron schedule to back up as often as you'd like in settings

## Common Use Cases

- Back up a Postgres database to R2
- Back up a Postgres database to S3 using Railway's native Cron instead of a long-running job

## Dependencies for Backup Postgres to R2 Hosting

- [Postgres](https://railway.com/deploy/postgres)

### Deployment Dependencies

- [Cloudflare R2](https://developers.cloudflare.com/r2/)

### Implementation Details

Internally, this uses [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) to dump the database and [rclone](https://rclone.org/) to sync the data with a folder in an R2 bucket.

You can modify the [generated rclone config](https://github.com/dbanty/rclone-postgres-backup/blob/main/entrypoint.sh#L8) to support virtually any other target for the backup.

## Why Deploy Backup Postgres to R2 on Railway?


Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Backup Postgres to R2 on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [N8N Main + Worker](https://railway.com/deploy/n8n-main-worker) — Deploy and Host N8N with Inactive worker.
- [Evolution API with n8n](https://railway.com/deploy/evolution-api-with-n8n) — [Jul'26] WhatsApp automation platform using Evolution API, n8n & PostgreSQL
- [Postgres Backup](https://railway.com/deploy/postgres-s3-backups) — Cron-based PostgreSQL backup to bucket storage

Open this page in a browser: https://railway.com/deploy/backup-postgres-to-r2
