Continuous backup and recovery are critical elements of database management. It ensures that your data is protected and can be quickly restored in case of any unexpected data loss or corruption. In Microsoft Azure Cosmos DB, configuring continuous backup and recovery can be easily achieved with a few steps. Throughout this article, we’ll demystify the steps and demonstrate how you can configure continuous backup and recovery for your native applications using Azure Cosmos DB.
Azure Cosmos DB’s Backup Types
Azure Cosmos DB provides two types of backups: periodic and continuous. Periodic backups are taken every four hours and retained for 30 days. However, Azure Cosmos DB’s continuous backup mode allows you to restore your data to any point within the last 30 days. The continuous backup mode significantly reduces potential data loss by continuously backing up your data in near real-time.
Setting up Continuous Backup Mode
First, let’s understand how we can enable continuous backup mode for your Cosmos DB account. To set up continuous backup mode, you need an existing Azure Cosmos account or you can create a new one.
- In the Azure portal, look for ‘Azure Cosmos DB’ and select it.
- Choose the Azure Cosmos account you want to create or modify.
- Go to ‘Settings’ and select ‘Backup Policy’.
- In the ‘Backup Policy’ window, select ‘Continuous’ mode.
- Click ‘Save’.
Setting Up Point-In-Time Restore
After setting up continuous backup mode, the next step is setting up point-in-time restore. Point-in-time restore enables you to create a new database restore at any point within the last 30 days.
Keep in mind that Point-in-time recovery is not automatically enabled; it must be configured. It can be configured using either the Azure portal, or Azure CLI or PowerShell.
For instance, you can enable point-in-time recovery via Azure portal:
- Go to the Azure portal and search for ‘Azure Cosmos DB’. Select it.
- Choose the Azure Cosmos account that you’ve configured for continuous backup mode.
- Under ‘Settings’, click ‘Point-in-time restore’.
- In the ‘Point-in-time restore’ window, select ‘Enable Continuous mode’.
- Click ‘Save’.
Restoring a Database
After so, anytime you want to restore a database, you should follow:
- In the Azure portal, look for ‘Azure Cosmos DB’ and select it.
- Choose the Azure Cosmos account you want to restore.
- Go to ‘Settings’ and select ‘Point-in-time restore’.
- Click on ‘+ New restore’.
- Configure the details of the restore including selecting the source and target, and specifying the restore point
- Click ‘Restore’
Additional Benefits of Azure Cosmos DB Continuous Mode
Additionally, Azure Cosmos DB continuous mode offers many benefits including unlimited backups, granular multi-region configurations, and more. It can be of great help during incidences of accidental deletes, regional failures, and more.
Conclusion
In conclusion, enabling and configuring continuous backup and recovery in Azure Cosmos DB is a crucial part of designing and implementing native applications. With Azure Cosmos DB’s user-friendly interface, ensuring the safety of your data is only a few clicks away. It is essential to familiarize yourself with these processes, as they can protect your data from unexpected loss and minimise the downtime of your applications.
Practice Test
True or False: The Azure Point in Time Restore (PITR) capability is mainly used for disaster recovery.
- True
- False
Answer: True
Explanation: PITR is primarily used to recover from accidental deletions or updates, which can be seen as a form of disaster recovery.
Which of the following backup types in Azure Cosmos DB can be configured on the portal, PowerShell, or CLI?
- A. Continuous backup
- B. Periodic backup
- C. On-demand backup
Answer: A. Continuous backup
Explanation: Continuous backup mode can be configured through the Azure portal, PowerShell, or the Azure CLI.
True or False: Azure Cosmos DB’s point-in-time restore allows for selective restoration.
- True
- False
Answer: False
Explanation: With point-in-time restore, you can only restore the entire Azure Cosmos DB account, not individual collections or databases.
Which of the following options does Azure Cosmos DB NOT support for backup and restore?
- A. Periodic backup
- B. Continuous backup
- C. On-demand backup
- D. Query-based backup
Answer: D. Query-based backup
Explanation: Query-based backup is not a feature available in Cosmos DB.
True or False: In Azure Cosmos DB, the retention period for continuous backups is 30 days.
- True
- False
Answer: True
Explanation: The retention period for continuous backups in Azure Cosmos DB is indeed 30 days.
True or False: The Decide frequency of backup policy in Azure Cosmos DB allows the user to configure the frequency of backup snapshots.
- True
- False
Answer: False
Explanation: The frequency of backup snapshots in Azure Cosmos DB is system-controlled and cannot be configured by the user.
What are the types of backup policy provided by Azure Cosmos DB?
- A. Decide frequency of backup
- B. Periodic backup
- C. Continuous backup
- D. On-demand backup
Answer: B. Periodic backup and C. Continuous backup
Explanation: Azure Cosmos DB provides two backup policies: Periodic and Continuous.
True or False: Azure Cosmos DB supports online backup and restore.
- True
- False
Answer: True
Explanation: Azure Cosmos DB supports online restoration where restored data is immediately available for access.
In Azure Cosmos DB, can users initiate on-demand backups?
- A. Yes
- B. No
Answer: B. No
Explanation: As of the current design, Azure Cosmos DB doesn’t support user-initiated on-demand backups.
True or False: Backup storage costs are separate and additional to your Azure Cosmos DB costs.
- True
- False
Answer: True
Explanation: Backup storage is billed separately and is not included in the provisioned throughput or consumed storage cost of your Azure Cosmos DB account.
Which of the following Azure Cosmos DB operations can change the restored state of your data?
- A. Delete Database
- B. Delete Container
- C. Create Trigger
- D. Create User
Answer: A. Delete Database and B. Delete Container
Explanation: Delete database and container operations can change the restored state of your data in Azure Cosmos DB.
True or False: You can restore to a point in time before your Azure Cosmos DB account was deleted.
- True
- False
Answer: False
Explanation: Once an Azure Cosmos DB account is deleted, all continuous backup data associated with the account is deleted.
In Azure Cosmos DB, what’s the default backup interval in Periodic backup mode?
- A. 1 hour
- B. 2 hours
- C. 4 hours
- D. 8 hours
Answer: C. 4 hours
Explanation: In periodic backup mode, Azure Cosmos DB automatically takes a backup of your data every 4 hours.
True or False: In the event of a regional outage, Azure Cosmos DB can restore your data in the same region.
- True
- False
Answer: False
Explanation: In the event of a regional outage, Azure Cosmos DB would restore your data to any region where your account has a replica.
Which of the following statement is true about backup storage in Azure Cosmos DB?
- A. Backup storage cost is included in your Azure Cosmos DB cost.
- B. Backup storage cost is separate and additional to your Azure Cosmos DB cost.
- C. There is no cost for backup storage in Azure Cosmos DB.
- D. Azure Cosmos DB doesn’t support backup storage.
Answer: B. Backup storage cost is separate and additional to your Azure Cosmos DB cost.
Explanation: Backup storage is billed separately on a monthly basis and it’s not included in your Azure Cosmos DB cost.
Interview Questions
What is Azure Cosmos DB?
Azure Cosmos DB is a globally distributed, multi-model database service from Microsoft for managing data at large-scale.
What is continuous back up in the context of Azure Cosmos DB?
Continuous backup mode allows recovery of data at any point in time within the retention period of 30 days.
What is the primary step to set up continuous backup in Azure Cosmos DB?
The primary step is to enable the continuous backup mode at account creation or you can switch an existing account to continuous backup mode.
How do you restore data in Azure Cosmos DB?
You restore data in Azure Cosmos DB by creating a new database restore request in the Azure portal.
What is the retention period for continuous backup in Azure Cosmos DB?
The retention period for continuous backup in Azure Cosmos DB is 30 days.
Is it possible to switch from periodic mode to continuous mode in Azure Cosmos DB?
Yes, you can switch from periodic mode to continuous mode but you need to remember that once an account is switched to continuous mode, it can’t be changed back to periodic mode.
What is the process to create a database restore in Azure Cosmos DB?
The process is to go to the Azure portal, select the Azure Cosmos DB account you want to restore to, select ‘Backup Policy’, and then ‘New Restore’.
Can we restore to an existing database or container with continuous backup in Azure Cosmos DB?
No, restore operation creates a new database or container. It does not restore to an existing database or container.
How do I view the restore status in Azure Cosmos DB?
You can view the restore status in the Azure portal on the ‘Backup Policy’ page of the Cosmos DB account.
Can I cancel the restore request in Azure Cosmos DB?
Yes, you can cancel the restore request in Azure Cosmos DB as long as the operation is still in progress.
What types of operations can be restored by using continuous backup in Azure Cosmos DB?
All create, delete and update operations on items, as well as creation and deletion of databases and containers can be restored.
Can we restore backup data to a different Azure region?
Yes, the backed up data can be restored in any of the Azure regions where the Cosmos DB database is replicated.
Is there any impact on the performance of Azure Cosmos DB while performing restore operation?
No, the restore operation in Azure CosmosDB is an asynchronous operation and it does not affect the performance of Cosmos DB.
When is the continuous backup mode helpful in Azure Cosmos DB?
Continuous backup mode is helpful when you need the ability to restore data at any point within the retention period, or when you need shorter Recovery Point Objective (RPO).
How are backups stored in Azure Cosmos DB’s continuous backup mode?
Continuous backup mode stores backups in a separate Azure Cosmos DB account that’s created specifically for storing backups. This guarantees that backups are separate from the source data and are accessible even if the source account is deleted.