Backup Postgres to R2
Backup Postgres to R2 (or S3) using Railway's Cron
rclone-postgres-backup
dbanty/rclone-postgres-backup
Just deployed
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. This should save some compute cost over a long-running job (like the official Railway template).
This template was created for Cloudflare R2, but it uses rclone 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:
- Configure environment variables for your database & R2 bucket
- Disable restarts
- 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
Deployment Dependencies
Implementation Details
Internally, this uses pg_dump to dump the database and rclone to sync the data with a folder in an R2 bucket.
You can modify the generated rclone config 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.
Template Content
rclone-postgres-backup
dbanty/rclone-postgres-backupR2_BUCKET
The name of the bucket to upload to
R2_ENDPOINT
The S3 API URL for your R2 account
R2_ACCESS_KEY_ID
An S3-compatible access key
R2_SECRET_ACCESS_KEY
An S3-compatible access key