Operations
Database Backup and Restore
Daily Postgres backups to S3-compatible object storage and restore commands.
Setup used in this repo
Backup runs as Kamal accessory db_backup with image:
eeshugerman/postgres-backup-s3:16
Configured in config/deploy.yml with:
SCHEDULE: "@daily"BACKUP_KEEP_DAYS: 7S3_ENDPOINT: https://nbg1.your-objectstorage.comS3_BUCKET: <your-existing-bucket>S3_PREFIX: backups
You can use any S3-compatible storage provider. Create the target bucket before enabling backup jobs.
Secrets used:
POSTGRES_PASSWORDS3_ACCESS_KEY_IDS3_SECRET_ACCESS_KEY
Start or restart backup accessory
kamal accessory reboot db_backupCheck backup logs
kamal accessory logs db_backupRun backup manually
kamal accessory exec db_backup "sh backup.sh"Restore latest backup
kamal accessory exec db_backup "sh restore.sh"Warning
Restore is destructive. Run it only when you are sure.
Verify
- Daily backups are visible in your configured S3 bucket.
- Backup logs show successful upload.
- Restore procedure is tested in a non-production environment.