Locating Restore Points
Complete the full lesson to earn 25 points — 50 with Pro
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks, the wait, and see fewer ads — read each lesson on a single page with Pro
Lesson: Locating Restore Points in Azure Cosmos DB
Introduction: Why Data Recovery Strategy Matters
In the world of distributed databases, the question is rarely "if" a data loss event will occur, but "when." Whether through an accidental deletion by an administrator, a faulty application logic bug that overwrites critical production data, or a catastrophic regional service outage, the ability to recover your data is the backbone of any enterprise-grade cloud architecture. Azure Cosmos DB provides sophisticated backup and restore capabilities, but these features are only as effective as your ability to identify the correct point in time to which you need to roll back.
Locating a restore point is more than just picking a timestamp from a calendar. It involves understanding the interplay between your backup mode, the retention window, and the specific state of your database at a granular level. When you are faced with a data recovery scenario, the pressure is often high, and the clock is ticking. Understanding exactly how to query for, verify, and select the right restore point is a critical skill for any database administrator or cloud architect. This lesson will walk you through the mechanisms of identifying these points, ensuring that when disaster strikes, you are prepared to act with precision.
Understanding Backup Modes in Cosmos DB
Before you can locate a restore point, you must understand the two primary backup modes offered by Azure Cosmos DB: Periodic and Continuous. Your choice of mode dictates how you search for and define a "restore point."
Periodic Backup Mode
In Periodic backup mode, backups are taken at regular intervals. The frequency and retention period are configured at the account level. When you need to restore, you are essentially looking for the most recent backup that occurred before the "incident" happened. The recovery point is a discrete snapshot.
Continuous Backup Mode
Continuous backup mode is significantly more granular. It allows for point-in-time restores (PITR) to any second within the retention window (up to 30 days). In this mode, you are not looking for a specific snapshot file; you are identifying a specific timestamp that represents the state of the database immediately preceding the data loss event.
Callout: Periodic vs. Continuous Backup Periodic backup is ideal for workloads where occasional data loss is acceptable or where RPO/RTO requirements are less stringent. Continuous backup is designed for mission-critical applications where data loss must be minimized to the lowest possible threshold, allowing for recovery to a specific second in time.
Identifying Restore Points: The Mechanics
When you initiate a restore operation, you are essentially creating a new Cosmos DB account based on the data present in the source account at a specific time. To locate the correct time, you must correlate application logs, audit logs, and database metrics.
Step 1: Correlating Incident Time to Restore Time
The most common mistake is guessing the time of an incident. If an application bug deletes records at 14:02 UTC, you cannot simply restore to 14:02, as the deletion might have already been processed. You need to identify the exact moment the event started and look for a point in time before that event.
Step 2: Using Azure Resource Graph
Azure Resource Graph is a powerful tool for exploring your resources. You can use it to verify the configuration of your backup settings, which confirms whether you are looking for a discrete snapshot or a continuous timeline.
// KQL query to identify backup mode for all Cosmos DB accounts
resources
| where type == "microsoft.documentdb/databaseaccounts"
| extend backupPolicy = properties.backupPolicy
| project name, backupPolicyType = backupPolicy.type
By running this query, you quickly verify which accounts are on Continuous mode, allowing you to proceed with a point-in-time search, versus those on Periodic mode, which require you to look for specific snapshot timestamps.
Working with Continuous Backup (PITR)
When you are in Continuous Backup mode, the "restore point" is a flexible variable. You have a window of time defined by your retention policy. To find the right point, you should use the Azure CLI or PowerShell to list available restore locations and times.
Listing Restoreable Resources via CLI
To identify the restore point, you need to check the restoreParameters of your resource. The following command helps you list the restoreable resources for a given account:
# Get the restoreable resources for a specific Cosmos DB account
az cosmosdb restorable-database-account list --instance-id <instance-id>
This command returns a list of objects that describe the account's state at various points. You will look for the startTime and endTime fields. These fields define the valid range for your recovery.
Practical Example: Finding the "Pre-Incident" Timestamp
Imagine your application suffered a mass-update error at 10:15 AM today. You need to find the latest valid restore point before that.
- Check Logs: Review your application's telemetry (e.g., Application Insights) to see when the failed process started.
- Verify Range: Use the Azure CLI to ensure 10:14 AM falls within the
minRestoreTimeandmaxRestoreTimefor your account. - Select Timestamp: Choose 10:14:30 AM as your target restore point to ensure you are before the corruption event.
Note: Always aim for a buffer of at least 30-60 seconds before the known incident time. This provides a safety margin in case the system clocks between your application server and the database were slightly out of sync.
Working with Periodic Backup
In Periodic mode, the process is slightly different because you are restricted to specific snapshots. You cannot restore to any second; you must restore to the time of the last successful backup.
Using the Azure Portal to Find Snapshots
- Navigate to your Cosmos DB account in the Azure Portal.
- Select the Backup & Restore blade.
- View the list of available backups.
- Note the specific timestamp of the backup you wish to restore.
Important Considerations for Periodic Backups
Because snapshots are taken at intervals (e.g., every 4 hours), your data loss window is defined by the interval. If you lose data at 10:00 AM and the last backup was at 8:00 AM, you will lose the changes made during those two hours. This is why it is vital to keep track of these intervals when planning your recovery strategy.
Best Practices for Locating Restore Points
Locating a restore point is a high-stakes activity. Following industry standards will help you avoid common pitfalls.
1. Maintain a "Last Known Good" Registry
Many administrators keep a log of major deployments or bulk updates. If you are performing a massive data migration or a schema update, record the exact UTC timestamp before you begin. This gives you a clear, pre-defined reference point if the operation fails.
2. Use Immutable Audit Logs
Application logs should be stored in an immutable format (like Azure Blob Storage with immutability policies). If your database is compromised, your application logs are your best source of truth for identifying when the incident occurred.
3. Test Your Recovery Regularly
A restore plan that has never been tested is not a plan; it is a hope. Conduct quarterly "fire drills" where you restore a production-like environment to a specific point in time. This forces you to practice locating the correct restore point and verifying the data integrity post-restore.
4. Monitor Restore Availability
Ensure that your retention policy matches your business requirements. If your business requires a 48-hour recovery window, but your Periodic backup is set to a 24-hour retention, you are failing your RPO (Recovery Point Objective).
Warning: Data Overlap When performing a restore, you are creating a new account. You cannot restore data directly back into the original account without first migrating it. Always plan for the storage cost and the networking overhead of moving data from the restored account back into your production environment.
Common Pitfalls and How to Avoid Them
Pitfall 1: Time Zone Confusion
One of the most frequent errors is miscalculating time zones. Cosmos DB uses UTC for all internal timestamps. If you are operating in a local time zone (e.g., EST or PST), always convert your incident time to UTC before searching for a restore point.
Pitfall 2: Neglecting the "Restore Window"
Some users assume they can restore from any point in the past. Remember that backups have a retention limit. If you need to recover a file deleted three weeks ago, but your retention is only 7 days, you will be unable to locate a valid restore point.
Pitfall 3: Not Verifying Data Consistency
After locating a restore point and initiating the restore, many users immediately point their application to the new database. Always perform a validation check on a subset of the data in the restored account to ensure the state is indeed what you expected before switching traffic.
Comparison: Locating Restore Points by Mode
| Feature | Periodic Backup | Continuous Backup |
|---|---|---|
| Granularity | Snapshot intervals (e.g., 4 hrs) | Point-in-time (to the second) |
| Search Method | List available snapshot timestamps | Query range between min/max time |
| Primary Tool | Azure Portal / CLI | CLI / PowerShell / SDK |
| Flexibility | Limited to specific snapshots | High (any time in retention window) |
| Best For | Non-critical, static workloads | Mission-critical, dynamic data |
Step-by-Step: Executing a Restore with a Selected Point
Once you have identified your target timestamp, follow these steps to initiate the recovery.
Step 1: Identify the Target
Suppose you identified 2023-10-27T10:14:00Z as your target. Ensure you have the resourceId of the original account.
Step 2: Initiate Restore via CLI
Use the following command to start the restoration process into a new account:
az cosmosdb restore \
--target-database-account-name "my-restored-account" \
--resource-group "my-resource-group" \
--restore-source "my-original-account-resource-id" \
--restore-timestamp "2023-10-27T10:14:00Z" \
--location "East US"
Step 3: Verify the Restore
The restore operation is asynchronous. You can monitor the status using:
az cosmosdb show \
--name "my-restored-account" \
--resource-group "my-resource-group" \
--query "provisioningState"
Once the state shows "Succeeded," you can connect to the new account and verify your data.
Deep Dive: The Role of Azure Service Health
Sometimes, a restore is not triggered by user error but by a service-level issue. If you suspect an issue with the underlying Cosmos DB service, check the Azure Service Health dashboard before attempting a restore. If there is a known regional outage, a restore might not be necessary or might even be ineffective until the service is fully restored.
Understanding the health of the infrastructure allows you to make an informed decision about whether a restore is the right path forward. If you restore while the underlying service is having issues, you risk adding latency or failure points to your recovery process.
Automation and Scripting for Large-Scale Environments
In large environments with hundreds of Cosmos DB accounts, manual restoration is unfeasible. You should script the identification of restore points.
Automating the Search
You can write a Python script using the azure-mgmt-cosmosdb library to iterate through all accounts, check their backup mode, and output the latest possible restore timestamp. This creates a "recovery catalog" that you can use in an emergency.
# Conceptual snippet for automating restore point identification
from azure.identity import DefaultAzureCredential
from azure.mgmt.cosmosdb import CosmosDBManagementClient
credential = DefaultAzureCredential()
client = CosmosDBManagementClient(credential, subscription_id="...")
def get_latest_restore_time(account_name, rg):
# Retrieve account details and check backup policy
account = client.database_accounts.get(rg, account_name)
if account.backup_policy.type == "Continuous":
# Logic to extract maxRestoreTime from account properties
return account.properties.restore_parameters.max_restore_time
return None
This proactive approach ensures that you aren't scrambling to find the "how-to" during an actual outage. By having a script ready to query these times, you reduce your RTO significantly.
Security Considerations for Restored Data
When you restore data, the new account is a fresh resource. It will have default security settings. You must ensure that:
- Access Control (RBAC): The new account has the same Role-Based Access Control settings as the original.
- Network Security: If the original account was locked down to a VNet or specific IP range, the new account must be configured with the same network rules.
- Encryption: Ensure the encryption settings (e.g., Customer-Managed Keys) are applied if required by your compliance policies.
Failure to replicate these settings can lead to "security leakage," where your restored data is accidentally exposed to unauthorized users or systems.
Dealing with Multi-Region Accounts
If your Cosmos DB account is replicated across multiple regions, the restore process is more complex. You need to consider which region you are restoring from. Typically, you restore into a single region and then configure the replication settings for the new account to match your production environment.
Always document your production replication topology. If you need to restore, you need to know exactly how many regions you need to re-enable to get back to full production parity.
Frequently Asked Questions (FAQ)
Can I restore just one container?
Yes, in many cases, you can restore individual databases or containers rather than the entire account. When you initiate the restore, you can specify the databasesToRestore or collectionsToRestore parameters to limit the scope of the recovery.
What happens to my original account during a restore?
The original account remains untouched. The restore process creates a new account. This is a key safety feature, as it prevents accidental overwriting of the original data while you are attempting to recover.
Is there a cost to keeping an account for restore purposes?
Yes, you are billed for the storage of the restored account. Once you have verified your data and migrated what you need, ensure you delete the restored account to avoid unnecessary charges.
Can I restore across subscriptions?
Yes, you can restore a Cosmos DB account to a different subscription, provided you have the appropriate permissions in both the source and target subscriptions. This is useful for moving data to a "sandbox" or "recovery" subscription.
Key Takeaways
- Precision is Paramount: Always correlate your restore timestamp with application logs to ensure you are restoring to the exact moment before data corruption occurred. A 60-second buffer is a recommended industry best practice.
- Know Your Backup Mode: Understand the difference between Periodic and Continuous modes. Periodic is snapshot-based, while Continuous allows for second-by-second granularity.
- Automate Discovery: Don't rely on manual processes during an emergency. Build scripts or use Resource Graph to maintain a catalog of valid restore points across your environment.
- Security Parity: A restored account is a new account. Always verify that your network rules, RBAC, and encryption settings match your production standards before allowing application traffic.
- Test Your Plan: Perform quarterly restoration drills. The time to find out that your restore process fails is during a test, not during a production outage.
- Mind the Cost: Restored accounts are separate, billable entities. Always decommission them once the data recovery process is complete to optimize your cloud spend.
- Document the Topology: For multi-region accounts, keep a clear record of your replication configuration to ensure you can quickly rebuild your production architecture after a restore.
By mastering the art of locating restore points, you transform your disaster recovery from a reactive, stressful event into a controlled, predictable operational task. Keep these principles in mind, and you will be well-positioned to protect your data assets against any unexpected scenario.
Reach the last section to complete this lesson and earn points — you're on section 1 of 11.
- Introduction to Cosmos DB Data Modeling
- Introduction to Cosmos DB Data Modeling Quiz5q
- Multiple Entity Types in Same Container
- Multiple Entity Types in Same Container Quiz5q
- Storing Related Entities in Same Document
- Storing Related Entities in Same Document Quiz5q
- Denormalizing Data Across Documents
- Denormalizing Data Across Documents Quiz5q
- Referencing Between Documents
- Referencing Between Documents Quiz5q
- Partition Keys and Document IDs
- Partition Keys and Document IDs Quiz5q
- Time to Live (TTL) Configuration
- Time to Live (TTL) Configuration Quiz5q
- Document Versioning Strategies
- Document Versioning Strategies Quiz5q
- Schema Versioning Patterns
- Schema Versioning Patterns Quiz5q
- Choosing Partition Strategies
- Choosing Partition Strategies Quiz5q
- Partition Key Selection Best Practices
- Partition Key Selection Best Practices Quiz5q
- Transactions and Partition Keys
- Transactions and Partition Keys Quiz5q
- Cross-Partition Query Costs
- Cross-Partition Query Costs Quiz5q
- Data Distribution Analysis
- Data Distribution Analysis Quiz5q
- Throughput Distribution Planning
- Throughput Distribution Planning Quiz5q
- Synthetic Partition Keys
- Synthetic Partition Keys Quiz5q
- Hierarchical Partition Keys
- Hierarchical Partition Keys Quiz5q
- Throughput and Storage Requirements
- Throughput and Storage Requirements Quiz5q
- Serverless vs Provisioned Throughput
- Serverless vs Provisioned Throughput Quiz5q
- Database-Level Provisioned Throughput
- Database-Level Provisioned Throughput Quiz5q
- Granular Scale Units
- Granular Scale Units Quiz5q
- Global Distribution Costs
- Global Distribution Costs Quiz5q
- Configuring Throughput in Portal
- Configuring Throughput in Portal Quiz5q
- Gateway vs Direct Connectivity Mode
- Gateway vs Direct Connectivity Mode Quiz5q
- Creating Database Connections
- Creating Database Connections Quiz5q
- Azure Cosmos DB Emulator
- Azure Cosmos DB Emulator Quiz5q
- Connection Error Handling
- Connection Error Handling Quiz5q
- Singleton Pattern for Clients
- Singleton Pattern for Clients Quiz5q
- Global Distribution Regions
- Global Distribution Regions Quiz5q
- Threading and Parallelism
- Threading and Parallelism Quiz5q
- Arrays and Nested Objects Queries
- Arrays and Nested Objects Queries Quiz5q
- Correlated Subqueries
- Correlated Subqueries Quiz5q
- Array and Type-Checking Functions
- Array and Type-Checking Functions Quiz5q
- Mathematical and String Functions
- Mathematical and String Functions Quiz5q
- Date Functions in Queries
- Date Functions in Queries Quiz5q
- Point Operations vs Query Operations
- Point Operations vs Query Operations Quiz5q
- CRUD Point Operations
- CRUD Point Operations Quiz5q
- Patch Operations for Updates
- Patch Operations for Updates Quiz5q
- Transactional Batch Operations
- Transactional Batch Operations Quiz5q
- Bulk Operations with SDK
- Bulk Operations with SDK Quiz5q
- Optimistic Concurrency with ETags
- Optimistic Concurrency with ETags Quiz5q
- Query Pagination and Continuation
- Query Pagination and Continuation Quiz5q
- Cosmos DB Mirroring for Fabric
- Cosmos DB Mirroring for Fabric Quiz5q
- Mirroring vs Spark Connector
- Mirroring vs Spark Connector Quiz5q
- Enabling Analytical Store
- Enabling Analytical Store Quiz5q
- Synapse Spark and SQL Queries
- Synapse Spark and SQL Queries Quiz5q
- Change Data Capture in Analytical Store
- Change Data Capture in Analytical Store Quiz5q
- Azure Functions and Event Hubs Integration
- Azure Functions and Event Hubs Integration Quiz5q
- Denormalization with Change Feed
- Denormalization with Change Feed Quiz5q
- Referential Integrity with Change Feed
- Referential Integrity with Change Feed Quiz5q
- Azure AI Search Integration
- Azure AI Search Integration Quiz5q
- Azure Functions Change Feed Trigger
- Azure Functions Change Feed Trigger Quiz5q
- Consuming Change Feed with SDK
- Consuming Change Feed with SDK Quiz5q
- Change Feed Estimator
- Change Feed Estimator Quiz5q
- Denormalization via Change Feed
- Denormalization via Change Feed Quiz5q
- Aggregation Persistence with Change Feed
- Aggregation Persistence with Change Feed Quiz5q
- Read-Heavy vs Write-Heavy Indexing
- Read-Heavy vs Write-Heavy Indexing Quiz5q
- Index Type Selection
- Index Type Selection Quiz5q
- Custom Indexing Policies
- Custom Indexing Policies Quiz5q
- Composite Index Implementation
- Composite Index Implementation Quiz5q
- Index Performance Optimization
- Index Performance Optimization Quiz5q
- Response Status Codes and Metrics
- Response Status Codes and Metrics Quiz5q
- Normalized RU Consumption Monitoring
- Normalized RU Consumption Monitoring Quiz5q
- Server-Side Latency Metrics
- Server-Side Latency Metrics Quiz5q
- Data Replication Monitoring
- Data Replication Monitoring Quiz5q
- Azure Monitor Alerts Configuration
- Azure Monitor Alerts Configuration Quiz5q
- Resource Logs Implementation
- Resource Logs Implementation Quiz5q
- Partition Throughput Monitoring
- Partition Throughput Monitoring Quiz5q
- Encryption Key Management
- Encryption Key Management Quiz5q
- Network-Level Access Control
- Network-Level Access Control Quiz5q
- Data Encryption Configuration
- Data Encryption Configuration Quiz5q
- Azure RBAC for Control Plane
- Azure RBAC for Control Plane Quiz5q
- Microsoft Entra ID for Data Plane
- Microsoft Entra ID for Data Plane Quiz5q
- CORS Settings Configuration
- CORS Settings Configuration Quiz5q
- Customer-Managed Keys
- Customer-Managed Keys Quiz5q
- Always Encrypted Implementation
- Always Encrypted Implementation Quiz5q
- Data Movement Strategy Selection
- Data Movement Strategy Selection Quiz5q
- SDK Bulk Operations for Data Movement
- SDK Bulk Operations for Data Movement Quiz5q
- Azure Data Factory Pipelines
- Azure Data Factory Pipelines Quiz5q
- Kafka Connector Integration
- Kafka Connector Integration Quiz5q
- Azure Stream Analytics Integration
- Azure Stream Analytics Integration Quiz5q
- Cosmos DB Spark Connector
- Cosmos DB Spark Connector Quiz5q
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles the points you earn on every lesson and quiz so you progress twice as fast, unlocks half of every practice exam — plus full case studies — with the Learn & Exam study modes, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× points per lesson & quiz
- ✓ 50% of every exam unlocked
- ✓ Learn & Exam modes
- ✓ Distraction-free lessons