Railway

Deploy postgres-s3-backup

Automated PostgreSQL backups to S3 with restore verification

Deploy postgres-s3-backup

Just deployed

PostgreSQL Backup & Restore Verification

Automated PostgreSQL backup system that dumps your database on a configurable schedule, compresses and optionally encrypts it with AES-256, then uploads to any S3-compatible storage provider. Includes a dedicated restore verification service that periodically downloads backups and restores them to a separate database to prove they actually work — because a backup you've never tested is a backup you can't trust.

About Hosting on Railway

This template deploys two services on Railway:

Backup Service — Runs pg_dump on a configurable interval (default: every hour), compresses the output with gzip, and uploads to your S3 bucket. Supports automatic retention management that cleans up backups older than your configured threshold (default: 7 days). Failed uploads are retried with exponential backoff. Optional AES-256-CBC encryption protects sensitive data at rest.

Verify Service — Performs automated restore drills on a separate schedule (default: every 24 hours). Downloads the latest backup from S3, restores it to an isolated verification database, runs integrity checks (table counts, row validation, custom SQL queries), then cleans up. Built-in safety checks prevent accidental restores to your production database.

Both services are lightweight containers built on postgres:16-alpine with minimal dependencies. You provide your own S3-compatible storage — AWS S3, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, or MinIO all work out of the box. Configure your database connection and S3 credentials as environment variables and the services start working immediately.

Common Use Cases

  • Scheduled production backups — Automatically back up your Railway PostgreSQL database to S3 on a configurable interval (hourly, daily, or custom)
  • Restore verification drills — Prove your backups are valid and recoverable with automated daily restore tests against an isolated database
  • Backup retention management — Automatically clean up old backups based on configurable retention policies to control storage costs
  • Encrypted backups — Protect sensitive production data with AES-256-CBC encryption before uploading to S3
  • Failure alerting — Get Slack, Discord, or webhook notifications when backups fail or restore verification detects issues
  • Compliance requirements — Meet data protection and disaster recovery requirements with documented, verified backup procedures

Configuration

Required Variables

VariableDescription
DATABASE_URLYour PostgreSQL connection string
S3_ENDPOINTS3-compatible endpoint URL
S3_BUCKETBucket name for storing backups
S3_ACCESS_KEY_IDS3 access key
S3_SECRET_ACCESS_KEYS3 secret key
VERIFY_DATABASE_URLSeparate database for restore testing

Optional Variables

VariableDefaultDescription
BACKUP_INTERVAL3600Backup frequency in seconds
BACKUP_RETENTION_DAYS7Days to retain backups
BACKUP_ENCRYPTIONfalseEnable AES-256 encryption
WEBHOOK_URLSlack/Discord webhook for notifications
VERIFY_INTERVAL86400Restore verification frequency in seconds
MIN_TABLE_COUNT0Minimum expected tables after restore

Features

  • Any S3 provider — AWS S3, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, MinIO
  • Configurable compression — Gzip levels 1-9 to balance speed vs size
  • Exponential backoff retries — Failed S3 uploads retry automatically
  • Structured logging — Clean, parseable log output with automatic secret scrubbing
  • Health checks — Built-in database and S3 connectivity monitoring
  • Graceful shutdown — Proper SIGTERM/SIGINT signal handling
  • Safety guards — Verify service validates it never targets your production database

Deploy and Host PostgreSQL Backup & Restore Verification on Railway

PostgreSQL Backup & Restore Verification is an automated backup system that dumps your database on a configurable schedule, compresses and optionally encrypts it with AES-256, then uploads to any S3-compatible storage. It includes a dedicated restore verification service that periodically restores backups to a separate database to prove they actually work — because a backup you've never tested is a backup you can't trust.

Why Deploy PostgreSQL Backup & Restore Verification on Railway

  • Zero-maintenance backups — Deploy once and your PostgreSQL database is automatically backed up on a schedule with configurable retention. No cron jobs to manage, no servers to maintain.
  • Proven recoverability — The built-in verify service performs automated restore drills daily, so you know your backups work before you need them in an emergency.
  • Flexible storage — Works with any S3-compatible provider (AWS S3, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, MinIO), so you control where your data lives and what you pay.
  • Production-ready out of the box — Includes AES-256 encryption, exponential backoff retries, structured logging with secret scrubbing, health checks, graceful shutdown, and webhook notifications to Slack or Discord.

About Hosting on Railway

This template deploys two services on Railway:

Backup Service — Runs pg_dump on a configurable interval (default: every hour), compresses the output with gzip, and uploads to your S3 bucket. Supports automatic retention management that cleans up backups older than your configured threshold (default: 7 days). Failed uploads are retried with exponential backoff. Optional AES-256-CBC encryption protects sensitive data at rest.

Verify Service — Performs automated restore drills on a separate schedule (default: every 24 hours). Downloads the latest backup from S3, restores it to an isolated verification database, runs integrity checks (table counts, row validation, custom SQL queries), then cleans up. Built-in safety checks prevent accidental restores to your production database.

Both services are lightweight containers built on postgres:16-alpine. Configure your database connection and S3 credentials as environment variables and the services start working immediately with sensible defaults.

Dependencies for PostgreSQL Backup & Restore Verification

Deployment Dependencies

  • PostgreSQL database — A running PostgreSQL instance to back up (Railway-managed or external)
  • S3-compatible storage — A bucket on any S3-compatible provider (AWS S3, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, or MinIO) with access credentials
  • Verification database — A separate PostgreSQL instance for restore testing (must be different from production to prevent accidental overwrites)

Common Use Cases

  • Scheduled production backups — Automatically back up your Railway PostgreSQL database to S3 on a configurable interval (hourly, daily, or custom)
  • Restore verification drills — Prove your backups are valid and recoverable with automated daily restore tests against an isolated database
  • Backup retention management — Automatically clean up old backups based on configurable retention policies to control storage costs
  • Encrypted backups — Protect sensitive production data with AES-256-CBC encryption before uploading to S3
  • Failure alerting — Get Slack, Discord, or webhook notifications when backups fail or restore verification detects issues
  • Compliance requirements — Meet data protection and disaster recovery requirements with documented, verified backup procedures

Configuration

Required Variables

VariableDescription
DATABASE_URLYour PostgreSQL connection string
S3_ENDPOINTS3-compatible endpoint URL
S3_BUCKETBucket name for storing backups
S3_ACCESS_KEY_IDS3 access key
S3_SECRET_ACCESS_KEYS3 secret key
VERIFY_DATABASE_URLSeparate database for restore testing

Optional Variables

VariableDefaultDescription
BACKUP_INTERVAL3600Backup frequency in seconds
BACKUP_RETENTION_DAYS7Days to retain backups
BACKUP_ENCRYPTIONfalseEnable AES-256 encryption
WEBHOOK_URLSlack/Discord webhook for notifications
VERIFY_INTERVAL86400Restore verification frequency in seconds
MIN_TABLE_COUNT0Minimum expected tables after restore

Features

  • Any S3 provider — AWS S3, Backblaze B2, Cloudflare R2, DigitalOcean Spaces, Wasabi, MinIO
  • Configurable compression — Gzip levels 1-9 to balance speed vs size
  • Exponential backoff retries — Failed S3 uploads retry automatically
  • Structured logging — Clean, parseable log output with automatic secret scrubbing
  • Health checks — Built-in database and S3 connectivity monitoring
  • Graceful shutdown — Proper SIGTERM/SIGINT signal handling
  • Safety guards — Verify service validates it never targets your production database

Template Content

More templates in this category

View Template
N8N Main + Worker
Deploy and Host N8N with Inactive worker.

jakemerson
View Template
Postgres Backup
Cron-based PostgreSQL backup to bucket storage

Railway Templates
View Template
Prefect [Updated Feb ’26]
Prefect [Feb ’26] (ETL & Automation alternative to Airflow) Self Host

shinyduo