Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Restore Operations

Restore databases from backups or point-in-time.

Restore Types

TypeUse CaseRPO
Backup RestoreFull database recoveryUp to 24 hours
PITR RestorePrecise recovery< 1 second

Backup Restore

List Available Backups

postbase cloud backups list -p myapp -d production
ID                    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:30

Restore to Same Database

postbase cloud backups restore bkp_D3uqtMIZ \
  -p myapp -d production --force

Restore 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-restored

PITR Restore

Point-in-Time Recovery allows restoring to any second within the recovery window.

Check Recovery Window

postbase cloud pitr status -p myapp -d production
Recovery Window:
  From:    2026-01-18 03:00:00
  To:      2026-01-25 14:45:00

Restore to Specific Time

postbase cloud pitr restore \
  -p myapp -d production \
  --target-time "2026-01-25T14:30:00Z" \
  --force

Restore to Latest

Restore to the most recent available state:

postbase cloud pitr restore \
  -p myapp -d production \
  --target-time latest \
  --force

Restore Process

What Happens During Restore

  1. Download - Backup files downloaded from R2
  2. Stop Connections - Active connections terminated
  3. Drop Data - Existing data removed
  4. Restore - pg_restore runs backup file
  5. WAL Replay (PITR only) - Replay transactions to target time
  6. Rebuild Indexes - Rebuild indexes for consistency
  7. Verify - Run integrity checks

Estimated Duration

OperationDuration
< 1 GB backup< 2 minutes
1-10 GB backup2-10 minutes
10-50 GB backup10-30 minutes
PITR + WAL replay+1-5 minutes

Monitoring Restore Progress

CLI

postbase cloud backups restore-status $RESTORE_ID -p myapp -d production
Restore Status
 
ID:       rstr_Abc123
Status:   in_progress
Progress: 65%
 
Started:  2026-01-25 14:30:00
Phase:    Restoring data
 
Estimated remaining: ~2 minutes

Watch Mode

postbase cloud backups restore-status $RESTORE_ID \
  -p myapp -d production --watch

Restore 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" \
  --force

Bad 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 --force

Application 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
  --force

Best 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 --force

Test 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 myapp

Document 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 integrity

Troubleshooting

Restore Failed

# Check restore status
postbase cloud backups restore-status $RESTORE_ID -p myapp -d production
 
# If failed, check logs
# Contact support with restore ID

Target Time Invalid

Error: Target time outside recovery window

Check the available recovery window:

postbase cloud pitr status -p myapp -d production

Incomplete Restore

If restore partially completed:

  1. Don't panic
  2. Create backup of current state (if possible)
  3. Retry the restore
  4. Contact support if persistent