Deploy Postgres Backup to Cloudflare R2 (S3-Compatible)

Automated PostgreSQL backups to S3-compatible storage with encryption

Deploy Postgres Backup to Cloudflare R2 (S3-Compatible)

Just deployed

Deploy and Host Postgres-to-R2 Backup on Railway

What is Postgres-to-R2 Backup?

Postgres-to-R2 Backup is an automated service that creates scheduled PostgreSQL backups and uploads them to S3-compatible object storage such as Cloudflare R2, AWS S3, Wasabi, Backblaze B2, or MinIO.

It supports optional gzip compression or 7z encryption, configurable backup retention, and both private and public database URLs, making PostgreSQL backups reliable, secure, and fully automated.


Hosting Postgres-to-R2 Backup on Railway

Deploying Postgres-to-R2 Backup on Railway involves creating a project, configuring environment variables, and deploying the service. Once running, the service:

  • Creates PostgreSQL backups using pg_dump
  • Compresses or encrypts backups
  • Uploads them to S3-compatible storage
  • Automatically deletes old backups based on retention settings

Railway handles container hosting, restarts, and logs, allowing you to automate backups without maintaining servers.


Common Use Cases

  • Automated daily or hourly PostgreSQL backups
  • Secure off-site storage of database snapshots
  • Automatic backup retention management

Dependencies

  • PostgreSQL database (cloud or self-hosted)
  • S3-compatible object storage credentials
  • Python 3.9+ (Docker uses Python 3.12)

Scheduling Backups on Railway

Postgres-to-R2 Backup schedules backups internally using the BACKUP_TIME environment variable (UTC).

You can:

  • Let the service run continuously (recommended)
  • Or use Railway Cron to trigger restarts if preferred

All scheduling defaults to UTC for consistent behavior across platforms.


Why Deploy Postgres-to-R2 Backup on Railway?

Railway provides a unified platform to deploy and manage your infrastructure. 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 Postgres-to-R2 Backup on Railway, you can automate secure PostgreSQL backups with minimal maintenance, freeing up time to focus on your application while ensuring reliable off-site backup storage.


Template Content

More templates in this category

View Template
ReadySet
A lightweight caching engine for Postgres

View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.

View Template
vchord-suite
One-click PostgreSQL with VectorChord, BM25, and hybrid search.