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
| Feature | Scheduled Backups | PITR |
|---|---|---|
| Frequency | Hourly/Daily/Weekly | Continuous |
| Data Loss | Up to schedule interval | Seconds |
| Recovery Points | Discrete snapshots | Any timestamp |
| Storage Cost | Lower | Higher |
| Processing Load | Peak during backup | Distributed |
| Best For | Cost-sensitive, low-change data | Critical data, compliance |
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:
- Firebase Audit Logs - Must be enabled in Google Cloud Console
- Service Account - Required for continuous monitoring
- 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:
- Go to Google Cloud Console
- Navigate to IAM & Admin > Audit Logs
- Find Cloud Firestore API
- Enable Data Read and Data Write logs
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:
- In FireBackup, navigate to Settings > Storage
- Upload a service account JSON with these roles:
roles/logging.viewer- Read audit logsroles/datastore.viewer- Read Firestore dataroles/datastore.importExportAdmin- Export/restore data
Step 3: Enable PITR for Project
- Navigate to the project's Settings tab
- Click Enable PITR
- Configure PITR settings (see below)
- Click Save
PITR Configuration Options
| Setting | Description | Default |
|---|---|---|
| Retention Period | How long to keep PITR data | 7 days |
| Collections | Which collections to monitor | All |
| Change Window Size | Grouping interval for changes | 1 minute |
| Storage Destination | Where to store PITR data | Default |
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
| Metric | Description |
|---|---|
| Changes Captured | Total changes recorded |
| Change Windows | Number of time windows |
| Storage Used | PITR storage consumption |
| Oldest Point | Earliest recoverable timestamp |
| Latest Point | Most recent recoverable timestamp |
Change Windows
View captured change windows:
| Column | Description |
|---|---|
| Start Time | Window start timestamp |
| End Time | Window end timestamp |
| Changes | Number of changes in window |
| Size | Storage size of window |
| Collections | Affected collections |
Pausing and Resuming PITR
Pause PITR
Temporarily stop change capture:
- Navigate to project PITR settings
- Click Pause PITR
- Confirm
When to pause:
- During maintenance windows
- When investigating issues
- For cost management during low-activity periods
While paused, changes are NOT captured. You cannot recover to timestamps during the paused period.
Resume PITR
Re-enable change capture:
- Navigate to project PITR settings
- Click Resume PITR
- Change capture resumes immediately
Point-in-Time Restore
Initiating a PITR Restore
- Navigate to project PITR settings
- Click Restore to Point in Time
- Select the target timestamp
- Choose restore options
- 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
| Option | Description |
|---|---|
| Target Project | Same or different project |
| Collections | All or selected collections |
| Merge Mode | Overwrite or merge |
| Preview | Dry run before actual restore |
PITR Restore Process
- Validation - Verify timestamp is within retention
- Base Selection - Find nearest full backup
- Change Replay - Apply changes up to target time
- Verification - Confirm restore integrity
PITR Restore Jobs
View and manage restore jobs:
Restore Job List
| Column | Description |
|---|---|
| ID | Unique job identifier |
| Target Time | Requested restore point |
| Status | Pending, Running, Completed, Failed |
| Progress | Percentage complete |
| Created | When 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
- Reduce retention period - Shorter retention uses less storage
- Exclude volatile collections - Don't track high-churn collections
- 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:
- Navigate to PITR settings
- Click Storage Management
- Select change windows to delete
- Confirm deletion
Deleting change windows removes the ability to restore to those timestamps.
Disabling PITR
To completely disable PITR:
- Navigate to project PITR settings
- Click Disable PITR
- Choose whether to keep or delete existing PITR data
- Confirm
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
- Set appropriate retention - Balance recovery needs with storage costs
- Exclude analytics collections - High-volume, low-value collections
- Monitor storage growth - Watch for unexpected growth
- 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:
- Audit logs not enabled in Google Cloud
- Service account lacks permissions
- PITR is paused
- Worker service is down
Solution:
- Verify audit log configuration
- Check service account permissions
- Check PITR status
- Contact support
PITR Lag Increasing
Possible causes:
- High change volume
- Storage latency
- Worker processing backlog
Solution:
- Monitor change volume
- Check storage destination health
- Scale worker capacity (Enterprise)
Restore Job Failed
Possible causes:
- Invalid timestamp (outside retention)
- Base backup unavailable
- Change window corrupted
- Insufficient permissions
Solution:
- Verify timestamp is within retention period
- Ensure at least one full backup exists
- Check change window integrity
- Verify service account permissions