Restore Operations
Restore databases from backups or point-in-time.
Restore Types
| Type | Use Case | RPO |
|---|---|---|
| Backup Restore | Full database recovery | Up to 24 hours |
| PITR Restore | Precise recovery | < 1 second |
Backup Restore
List Available Backups
postbase cloud backups list -p myapp -d productionID TYPE STATUS SIZE CREATED
bkp_D3uqtMIZ... automated completed 12.5 MB 2026-01-25 03:00
bkp_K9Rvw2Hx... automated completed 12.3 MB 2026-01-24 03:00
bkp_ManualXyz... manual completed 12.1 MB 2026-01-23 14:30Restore to Same Database
postbase cloud backups restore bkp_D3uqtMIZ \
-p myapp -d production --forceRestore to New Database
# Provision new database
postbase cloud provision production-restored -p myapp
# Restore backup to new database
postbase cloud backups restore bkp_D3uqtMIZ \
-p myapp -d production-restoredPITR Restore
Point-in-Time Recovery allows restoring to any second within the recovery window.
Check Recovery Window
postbase cloud pitr status -p myapp -d productionRecovery Window:
From: 2026-01-18 03:00:00
To: 2026-01-25 14:45:00Restore to Specific Time
postbase cloud pitr restore \
-p myapp -d production \
--target-time "2026-01-25T14:30:00Z" \
--forceRestore to Latest
Restore to the most recent available state:
postbase cloud pitr restore \
-p myapp -d production \
--target-time latest \
--forceRestore Process
What Happens During Restore
- Download - Backup files downloaded from R2
- Stop Connections - Active connections terminated
- Drop Data - Existing data removed
- Restore - pg_restore runs backup file
- WAL Replay (PITR only) - Replay transactions to target time
- Rebuild Indexes - Rebuild indexes for consistency
- Verify - Run integrity checks
Estimated Duration
| Operation | Duration |
|---|---|
| < 1 GB backup | < 2 minutes |
| 1-10 GB backup | 2-10 minutes |
| 10-50 GB backup | 10-30 minutes |
| PITR + WAL replay | +1-5 minutes |
Monitoring Restore Progress
CLI
postbase cloud backups restore-status $RESTORE_ID -p myapp -d productionRestore Status
ID: rstr_Abc123
Status: in_progress
Progress: 65%
Started: 2026-01-25 14:30:00
Phase: Restoring data
Estimated remaining: ~2 minutesWatch Mode
postbase cloud backups restore-status $RESTORE_ID \
-p myapp -d production --watchRestore Verification
Check Data
# Connect and verify
postbase cloud psql -p myapp -d production
-- Check row counts
SELECT 'users' as table, COUNT(*) FROM users
UNION ALL
SELECT 'posts', COUNT(*) FROM posts
UNION ALL
SELECT 'comments', COUNT(*) FROM comments;Check Schema
postbase cloud psql -p myapp -d production -c "\dt"Check Recent Data
postbase cloud psql -p myapp -d production \
-c "SELECT * FROM users ORDER BY created_at DESC LIMIT 5"Rollback Scenarios
Accidental Deletion
-- Oops!
DELETE FROM users WHERE active = false; -- Deleted 1000 users
-- Check PITR window
postbase cloud pitr status -p myapp -d production
-- Restore to 5 minutes ago
postbase cloud pitr restore \
-p myapp -d production \
--target-time "2026-01-25T14:25:00Z" \
--forceBad Migration
# Migration went wrong
postbase migrate up # Corrupted data
# Find last good backup
postbase cloud backups list -p myapp -d production
# Restore
postbase cloud backups restore bkp_BeforeMigration \
-p myapp -d production --forceApplication Bug
// Bug in code wrote bad data
await db.from('orders').update({ total: 0 }) // All orders now $0
// Use PITR to go back
postbase cloud pitr restore \
-p myapp -d production \
--target-time "2026-01-25T10:00:00Z" \ // Before the bug
--forceBest Practices
Pre-Restore Backup
Before restoring to production, create a backup of current state:
# Backup current state
postbase cloud backups create -p myapp -d production
# Then restore
postbase cloud backups restore $OLD_BACKUP_ID -p myapp -d production --forceTest Restores First
Restore to a test database before production:
# Create test database
postbase cloud provision restore-test -p myapp
# Restore to test
postbase cloud backups restore $BACKUP_ID -p myapp -d restore-test
# Verify data
postbase cloud psql -p myapp -d restore-test \
-c "SELECT COUNT(*) FROM users"
# If good, restore to production
postbase cloud backups restore $BACKUP_ID -p myapp -d production --force
# Cleanup
postbase cloud destroy restore-test -p myappDocument Recovery
Keep a recovery runbook:
## Recovery Runbook
### Accidental Data Deletion
1. Identify when deletion occurred
2. Check PITR window: `postbase cloud pitr status`
3. Restore to pre-deletion time: `postbase cloud pitr restore --target-time "..."`
### Full Database Recovery
1. List backups: `postbase cloud backups list`
2. Select appropriate backup
3. Restore: `postbase cloud backups restore`
4. Verify data integrityTroubleshooting
Restore Failed
# Check restore status
postbase cloud backups restore-status $RESTORE_ID -p myapp -d production
# If failed, check logs
# Contact support with restore IDTarget Time Invalid
Error: Target time outside recovery windowCheck the available recovery window:
postbase cloud pitr status -p myapp -d productionIncomplete Restore
If restore partially completed:
- Don't panic
- Create backup of current state (if possible)
- Retry the restore
- Contact support if persistent