Backup and Restore: Periodic vs Continuous
Choose between periodic and continuous backup for Cosmos DB, configure backup policies, understand point-in-time restore, and know the cost and operational implications of each.
Backup: your safety net
Think of backups like snapshots of your entire filing cabinet. Periodic backup takes a photo every few hours β if something goes wrong, you can restore from the last photo, but you lose changes since then. Continuous backup records every change as it happens β you can rewind to any second.
Marcusβs backup strategy
βοΈ Marcus at FinSecure handles financial data with strict RPO (Recovery Point Objective) requirements:
- Transaction database: Continuous backup with a 30-day recovery window; verify the latest restorable timestamp against the required RPO
- Analytics database: RPO = 4 hours (periodic backup, cost-effective)
- Compliance requirement: All restores must be to a new account for audit isolation
Periodic backup
The default backup mode. Cosmos DB takes full snapshots automatically:
| Setting | Options | Default |
|---|---|---|
| Interval | 1-24 hours | 4 hours |
| Retention | 2Γ interval to 720 hours (30 days max) | 8 hours (2 copies) |
| Redundancy | Locally redundant, Zone-redundant, Geo-redundant | Geo-redundant |
# Configure periodic backup
az cosmosdb update --name finsecure-cosmos \
--resource-group rg-finsecure \
--backup-interval 60 \
--backup-retention 168 \
--backup-redundancy "Geo"
Key limitations:
- Cannot self-restore β you must contact Azure Support for periodic backup restore
- RPO = backup interval (if interval is 4 hours, you can lose up to 4 hours of data)
- Backups are stored separately and donβt consume your account storage
Continuous backup
Continuous backup enables point-in-time restore (PITR) β restore to any second:
| Feature | Continuous 7-day | Continuous 30-day | Continuous 35-day |
|---|---|---|---|
| Retention | 7 days | 30 days | 35 days |
| Restore granularity | Timestamp within available backup | Timestamp within available backup | Timestamp within available backup |
| Self-service restore | Yes | Yes | Yes |
| Backup storage charge | No additional storage charge | Additional charge | Additional charge |
| Restore charge | Charged | Charged | Charged |
| Restore target | New account; eligible deleted resources into existing account | New account; eligible deleted resources into existing account | New account; eligible deleted resources into existing account |
# Enable continuous backup (30-day) on a new account
az cosmosdb create --name finsecure-transactions \
--resource-group rg-finsecure \
--backup-policy-type Continuous \
--continuous-tier Continuous30Days
# Point-in-time restore
az cosmosdb restore --account-name finsecure-transactions \
--resource-group rg-finsecure \
--target-database-account-name finsecure-restored \
--restore-timestamp "<timestamp-within-the-available-backup-window>" \
--location "eastus"
Exam tip: restore options for continuous backup
Continuous backup supports restoring to a new account or to an existing account (for restoring deleted containers/databases). Periodic backup restore always creates a new account and requires contacting Azure Support. Key details:
- Restoring to an existing account is preferred for deleted containers/databases (avoids data transfer cost)
- Restoring to a new account is preferred for accidental data modification scenarios
- The original account remains untouched when restoring to a new account
- Data and index properties are restored; throughput settings might not match the restore point
- Reapply firewall, private endpoint and RBAC settings; stored procedures, triggers and UDFs are not restored
- The restored account gets a new name that you specify (for new account restores)
The exam may test this distinction β know that continuous backup now has both options, while periodic always needs a support ticket and new account.
Periodic vs continuous comparison
| Aspect | Periodic Backup | Continuous Backup |
|---|---|---|
| RPO | Depends on the available snapshot | Check latest restorable timestamp; backups are asynchronous |
| Self-service restore | β Contact Azure Support | β Self-service via portal/CLI |
| Granularity | Full snapshot at interval | Any second within retention |
| Retention | Up to 30 days | 7, 30 or 35 days |
| Extra cost | Depends on retained backup copies | Storage charge for 30/35-day; restores charged for all tiers |
| Restore target | New account | New account or existing account |
| When to use | Snapshot-level recovery is sufficient | Fine-grained recovery from deletion or corruption |
π¬ Video walkthrough
Flashcards
Knowledge Check
Marcus needs fine-grained timestamp recovery within 30 days and self-service restore. Which listed backup mode meets those requirements?
A developer accidentally deletes a container at 2:15 PM. The account uses continuous backup with 30-day retention. What's the restore process?
Official references
- Continuous backup, retention tiers and restore limitations
- Restore an account using continuous backup
Next up: Network Security β firewalls, VNets, private endpoints, and CORS for securing access to your Cosmos DB account.