For DevelopersServices
Cleanup Cron Service (crons/cleanup
)
Scheduled cleanup for S3 storage.
What it does
- Lists all files via
S3Client
- Filters
pg-backups/
files - Deletes backup files older than 1 year
- Sentry traces + errors
Environment (src/env.ts
)
ENV_NAME
,S3_ACCESS_KEY_ID
,S3_SECRET_ACCESS_KEY
,S3_REGION
,S3_BUCKET
,S3_ENDPOINT
,SENTRY_DSN_CRON_CLEANUP
Implementation (src/index.ts
)
- Batches through S3 listings with cursors
- Parses dates from
pg-backup-<ISO>.sql.gz
- Deletes old items with
del()
Docker image (crons/cleanup/Dockerfile
)
- Bun base; prod deps; non-root
Railway (crons/cleanup/railway.json
)
- Schedule:
0 5 * * *
- 1 replica, CPU 4, 16GB mem