Skip to main content

Point-in-Time Recovery (PITR)

Point-in-Time Recovery (PITR) enables continuous data protection by capturing every change to your Firestore database. This allows you to restore your data to any specific moment in time, providing granular recovery options beyond traditional scheduled backups.

What is PITR?

PITR continuously monitors your Firestore database and captures all changes (creates, updates, deletes) in real-time. Unlike scheduled backups that create periodic snapshots, PITR provides:

  • Continuous protection - Every change is captured
  • Granular recovery - Restore to any second, not just backup times
  • Minimal data loss - Recovery Point Objective (RPO) of seconds
  • Compliance support - Full audit trail of data changes

PITR vs Scheduled Backups

FeatureScheduled BackupsPITR
FrequencyHourly/Daily/WeeklyContinuous
Data LossUp to schedule intervalSeconds
Recovery PointsDiscrete snapshotsAny timestamp
Storage CostLowerHigher
Processing LoadPeak during backupDistributed
Best ForCost-sensitive, low-change dataCritical data, compliance
Recommendation

For critical production data, use both PITR and scheduled full backups. PITR provides granular recovery, while full backups provide independent restore points.

Enabling PITR

Prerequisites

Before enabling PITR:

  1. Firebase Audit Logs - Must be enabled in Google Cloud Console
  2. Service Account - Required for continuous monitoring
  3. Storage Destination - PITR data needs dedicated storage

Step-by-Step Setup

Step 1: Enable Firebase Audit Logs

PITR requires Firestore audit logging to be enabled:

  1. Go to Google Cloud Console
  2. Navigate to IAM & Admin > Audit Logs
  3. Find Cloud Firestore API
  4. Enable Data Read and Data Write logs
Audit Log Costs

Enabling audit logs incurs Google Cloud logging costs. See Google Cloud Pricing for details.

Step 2: Configure Service Account

PITR requires a service account with appropriate permissions:

  1. In FireBackup, navigate to Settings > Storage
  2. Upload a service account JSON with these roles:
    • roles/logging.viewer - Read audit logs
    • roles/datastore.viewer - Read Firestore data
    • roles/datastore.importExportAdmin - Export/restore data

Step 3: Enable PITR for Project

  1. Navigate to the project's Settings tab
  2. Click Enable PITR
  3. Configure PITR settings (see below)
  4. Click Save

PITR Configuration Options

SettingDescriptionDefault
Retention PeriodHow long to keep PITR data7 days
CollectionsWhich collections to monitorAll
Change Window SizeGrouping interval for changes1 minute
Storage DestinationWhere to store PITR dataDefault

PITR Dashboard

Once enabled, the PITR dashboard shows:

Health Status

  • Status: Active, Paused, or Error
  • Last Change Captured: Timestamp of last recorded change
  • Lag: Time behind real-time
  • Health Score: Overall system health

Statistics

MetricDescription
Changes CapturedTotal changes recorded
Change WindowsNumber of time windows
Storage UsedPITR storage consumption
Oldest PointEarliest recoverable timestamp
Latest PointMost recent recoverable timestamp

Change Windows

View captured change windows:

ColumnDescription
Start TimeWindow start timestamp
End TimeWindow end timestamp
ChangesNumber of changes in window
SizeStorage size of window
CollectionsAffected collections

Pausing and Resuming PITR

Pause PITR

Temporarily stop change capture:

  1. Navigate to project PITR settings
  2. Click Pause PITR
  3. Confirm

When to pause:

  • During maintenance windows
  • When investigating issues
  • For cost management during low-activity periods
Gap in Protection

While paused, changes are NOT captured. You cannot recover to timestamps during the paused period.

Resume PITR

Re-enable change capture:

  1. Navigate to project PITR settings
  2. Click Resume PITR
  3. Change capture resumes immediately

Point-in-Time Restore

Initiating a PITR Restore

  1. Navigate to project PITR settings
  2. Click Restore to Point in Time
  3. Select the target timestamp
  4. Choose restore options
  5. Click Start Restore

Timestamp Selection

Use the timestamp picker to select your recovery point:

  • Calendar view - Select date
  • Time slider - Select hour/minute/second
  • Manual input - Enter exact ISO timestamp

The UI shows which timestamps are available based on your retention period.

Restore Options

OptionDescription
Target ProjectSame or different project
CollectionsAll or selected collections
Merge ModeOverwrite or merge
PreviewDry run before actual restore

PITR Restore Process

  1. Validation - Verify timestamp is within retention
  2. Base Selection - Find nearest full backup
  3. Change Replay - Apply changes up to target time
  4. Verification - Confirm restore integrity

PITR Restore Jobs

View and manage restore jobs:

Restore Job List

ColumnDescription
IDUnique job identifier
Target TimeRequested restore point
StatusPending, Running, Completed, Failed
ProgressPercentage complete
CreatedWhen job was created

Restore Job Details

Click on a job to view:

  • Configuration - Target time, options, collections
  • Progress - Current phase and percentage
  • Logs - Detailed execution logs
  • Result - Success/failure with details

Managing PITR Storage

Storage Consumption

PITR storage grows with:

  • Change volume - More changes = more storage
  • Retention period - Longer retention = more storage
  • Document size - Larger documents = more storage

Monitor storage in the PITR dashboard.

Reducing PITR Storage

  1. Reduce retention period - Shorter retention uses less storage
  2. Exclude volatile collections - Don't track high-churn collections
  3. Increase change window size - Larger windows consolidate storage

PITR Storage Cleanup

Storage is automatically cleaned up based on retention policy. You can also manually clean up:

  1. Navigate to PITR settings
  2. Click Storage Management
  3. Select change windows to delete
  4. Confirm deletion
Cleanup Warning

Deleting change windows removes the ability to restore to those timestamps.

Disabling PITR

To completely disable PITR:

  1. Navigate to project PITR settings
  2. Click Disable PITR
  3. Choose whether to keep or delete existing PITR data
  4. Confirm
Disabling PITR

Once disabled, continuous change capture stops. Existing PITR data can be retained for historical restores.

PITR API

Enable PITR

POST /api/v1/pitr/enable
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
"projectId": "project-123",
"config": {
"retentionDays": 7,
"collections": ["users", "orders"],
"changeWindowMinutes": 1,
"storageDestinationId": "storage-456"
}
}

Get PITR Configuration

GET /api/v1/pitr/{projectId}/config
Authorization: Bearer YOUR_TOKEN

Get PITR Statistics

GET /api/v1/pitr/{projectId}/statistics
Authorization: Bearer YOUR_TOKEN

Get PITR Health

GET /api/v1/pitr/{projectId}/health
Authorization: Bearer YOUR_TOKEN

List Change Windows

GET /api/v1/pitr/{projectId}/windows
Authorization: Bearer YOUR_TOKEN

Create PITR Restore Job

POST /api/v1/pitr/restore
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN

{
"projectId": "project-123",
"targetTimestamp": "2024-01-15T10:30:00Z",
"options": {
"collections": ["users"],
"mergeMode": "overwrite",
"targetProjectId": "project-456"
}
}

Get Restore Job Status

GET /api/v1/pitr/{projectId}/restore-jobs/{jobId}
Authorization: Bearer YOUR_TOKEN

See API Reference for complete documentation.

Best Practices

PITR Configuration

  1. Set appropriate retention - Balance recovery needs with storage costs
  2. Exclude analytics collections - High-volume, low-value collections
  3. Monitor storage growth - Watch for unexpected growth
  4. Test restores regularly - Verify PITR works before you need it

Compliance Use Cases

PITR supports compliance requirements:

  • SOC 2 - Audit trail of all data changes
  • GDPR - Ability to restore data for subject access requests
  • HIPAA - Data integrity and recovery capabilities
  • PCI DSS - Data protection and recovery

Combining with Scheduled Backups

Recommended configuration:

PITR: Enabled with 7-day retention
Full Backup: Weekly
Incremental Backup: Daily

This provides:

  • Point-in-time recovery for recent data (7 days)
  • Weekly restore points for older data
  • Daily restore points between full backups

Troubleshooting

PITR Not Capturing Changes

Possible causes:

  1. Audit logs not enabled in Google Cloud
  2. Service account lacks permissions
  3. PITR is paused
  4. Worker service is down

Solution:

  1. Verify audit log configuration
  2. Check service account permissions
  3. Check PITR status
  4. Contact support

PITR Lag Increasing

Possible causes:

  1. High change volume
  2. Storage latency
  3. Worker processing backlog

Solution:

  1. Monitor change volume
  2. Check storage destination health
  3. Scale worker capacity (Enterprise)

Restore Job Failed

Possible causes:

  1. Invalid timestamp (outside retention)
  2. Base backup unavailable
  3. Change window corrupted
  4. Insufficient permissions

Solution:

  1. Verify timestamp is within retention period
  2. Ensure at least one full backup exists
  3. Check change window integrity
  4. Verify service account permissions

Next Steps