For DevelopersServices
Backup Cron Service (crons/backup
)
Daily PostgreSQL backup to S3 storage. Gzips output; runs on Railway schedule.
What it does
- Runs
pg_dump
againstDATABASE_URL
- Gzips dump, uploads to
pg-backups/
in private S3 storage - Sentry traces + errors
Environment (src/env.ts
)
SENTRY_DSN_CRON_BACKUP
,ENV_NAME
,DATABASE_URL
,S3_ACCESS_KEY_ID
,S3_SECRET_ACCESS_KEY
,S3_REGION
,S3_BUCKET
,S3_ENDPOINT
Implementation (src/index.ts
)
- Spawns
pg_dump
(PostgreSQL 16 client installed in Dockerfile) - Compress → upload via
S3Client
- Flushes Sentry on success/error, exits with proper code
Docker image (crons/backup/Dockerfile
)
- Bun base; installs PostgreSQL client; prod deps only; runs as non-root
Railway (crons/backup/railway.json
)
- Schedule:
0 5 * * *
- 1 replica, CPU 4, 16GB mem