Configuring periodic backups is a crucial task for maintaining the integrity and reliability of the applications designed and implemented using Microsoft Azure Cosmos DB. It enables developers and IT Management professionals to develop data-level recovery strategies if and when required. With Cosmos DB, not only can users restore data to any point within the configured backup retention period, but they can also modify the backup interval and retention period according to the specific needs.

Table of Contents

Configuring Periodic Backups in Azure Cosmos DB

There are two primary ways to conduct periodic backups on Azure Cosmos DB:

  1. Automatic Periodic Backup
  2. Continuous Backup

Automatic Periodic Backup

By default, Azure Cosmos DB automatically takes a snapshot of your data every four hours. Cosmos DB can restore your data to the state it was in at the time of the snapshot.

The automatic backup service takes backups of your data without affecting the performance or availability of your operations. The recent four hourly backups and 2 daily backups from the past 30 days are stored and you can request Azure support to restore your data from these backups.

To configure periodic backups, the following are the steps to be taken:

  • Go to the Azure portal
  • Find and click on Azure Cosmos DB on the dashboard.
  • Select the desired account for which to configure the backup.
  • In the left menu, scroll down to “Settings” and click on “Backup Policy”.
  • Through this, one can enable automatic periodic backups.

It should be noted that after initiating the backup process, it will take some time to carry out the procedure and the time taken will be dependent on the size of your database.

Continuous Backup

On the other hand, Azure Cosmos DB’s continuous backup mode is the second way to back up data. With this feature, Cosmos DB continually backs up your data which makes your data always recoverable. This mode provides the ability to restore data at any point in time within the last 30 days.

To enable the continuous backup for your Cosmos DB account, you can use Azure portal, Azure CLI or PowerShell or ARM templates.

Below is an example of enabling continuous backup using Azure CLI:


az cosmosdb update –name MyAzureCosmosDB –resource-group MyResourceGroup –backup-policy-type Continuous

In this command, replace ‘MyAzureCosmosDB’ with your Azure Cosmos DB account name and replace ‘MyResourceGroup’ with your resource group name.

It’s essential to note that once you change your backup policy type from periodic to continuous, you can’t change it back to periodic.

Comparison between Automatic and Continuous backups

Automatic Periodic Backup Continuous Backup
Default enabled Need to manually enable
Restore from last 4-hourly or 2 daily backups Restore at any point in time
Cannot recover data deleted mistakenly after the last backup Can recover data deleted accidentally at any time within the last 30 days
Changing the backup interval or retention period applicable Custom backup intervals and periods are inapplicable

Irrespective of the backup type chosen, creating a recovery strategy using Azure Cosmos DB’s backup functionalities is critical in maintaining and safeguarding your data and ensuring that your native applications can withstand, adapt to, and recover from data loss incidents.

Practice Test

True or False: Azure Cosmos DB provides an automatic periodic backup feature?

  • True
  • False

Answer: True

Explanation: Azure Cosmos DB has a built-in automatic periodic backup feature that enables protection of data without any additional cost.

Which type of backup provides point-in-time restoration in Azure Cosmos DB?

  • Full Backup
  • Periodic Backup
  • Continuous Backup
  • None of the above

Answer: Continuous Backup

Explanation: The Continuous Backup mode in Azure Cosmos DB enables point-in-time restore capability.

True or False: The retention period for Azure Cosmos DB’s periodic backups can be configured up to 8 days.

  • True
  • False

Answer: True

Explanation: The retention period for Azure’s automatic periodic backup can be configured from 1 to 8 days.

Which of the following statements are true about Azure Cosmos DB backups? (Select all that apply)

  • Backups for Azure Cosmos DB are stored in the same region as the original data.
  • Azure Cosmos DB backups are only retained for 24 hours.
  • Backup data can only be restored by Azure support and is a chargeable service.
  • Azure Cosmos DB backups are incremental.

Answer: Backups for Azure Cosmos DB are stored in the same region as the original data, Backup data can only be restored by Azure support and is a chargeable service, Azure Cosmos DB backups are incremental.

Explanation: Azure Cosmos DB backups are not stored in a different region. Backup data can only be restored by Azure support and the operation is not free. Moreover, backups are incremental, which do not use any additional storage.

True or False: Changes to the backup interval or backup retention period in Azure Cosmos DB takes place immediately.

  • True
  • False

Answer: False

Explanation: Changes to the Azure Cosmos DB backup policy, like backup interval or backup retention period, may take up to 24 hours to take effect.

True or False: Azure Cosmos DB’s automatic backup feature is included in the database price?

  • True
  • False

Answer: True

Explanation: Azure Cosmos DB’s built-in automatic backup feature is included in the cost of the database. No additional charges are incurred.

What are the maximum and minimum values for the backup interval in Azure Cosmos DB?

  • Max 1440 mins, Min 60 mins
  • Max 60 mins, Min 5 mins
  • Max 720 mins, Min 15 mins
  • Max 60 mins, Min 1 min

Answer: Max 1440 mins, Min 60 mins

Explanation: The backup interval in Azure Cosmos DB can be configured from a minimum of 60 minutes to a maximum of 1440 minutes.

Which backup policy is enabled by default in Azure Cosmos DB?

  • Continuous Backup policy
  • Periodic Backup policy
  • Full Backup policy
  • None

Answer: Periodic Backup policy

Explanation: By default, Azure Cosmos DB enables the Periodic Backup policy for backing up data.

True or False: In Azure Cosmos DB, two backups are kept, which are taken at different points in time.

  • True
  • False

Answer: True

Explanation: Azure Cosmos DB keeps two backups, with both of them taken at different points in time to ensure data safety and reliability.

Is it possible to restore data from a specific point in time using the periodic backup feature in Azure Cosmos DB?

  • Yes
  • No

Answer: No

Explanation: Periodic backup does not support point-in-time restores. This capability is only available with the continuous backup feature in Azure Cosmos DB.

Interview Questions

What is a periodic backup in the context of Microsoft Azure Cosmos DB?

A periodic backup in Microsoft Azure Cosmos DB is a scheduled recurring backup operation. It automatically creates backups of your data at regular intervals to protect against data loss from accidental delete operations, disasters, or application bugs.

How does Azure Cosmos DB perform backups?

Azure Cosmos DB automatically takes periodic and automatic backups of all data at regular intervals without affecting the performance or availability of your operations. Backups are done every four hours by default.

Can we configure the backup interval in Azure Cosmos DB?

No, as of now, we cannot configure the backup interval. Azure Cosmos DB’s backup interval is set to 4 hours by default.

When are the automatic snapshots of data taken in Azure Cosmos DB?

By default, Azure Cosmos DB stores the latest two backups taken in an interval of around four hours.

How is backup storage billed in Azure Cosmos DB?

Azure Cosmos DB includes the cost of backups in the price, so you don’t pay extra for backups.

Where are backups in Azure Cosmos DB stored?

Backups are stored separately within Azure Cosmos DB’s internal storage, separate from the operational storage associated with the account.

How can Azure Cosmos DB ensure the durability of backups?

Azure Cosmos DB ensures the durability of backups by automatically creating and maintaining them at frequent intervals, apart from replicating data across multiple regions for higher availability.

Is it possible to download or export Azure Cosmos DB automatic backups?

No, it is not currently possible to download or export Azure Cosmos DB automatic backups. If data recovery is required, it can be achieved through Azure support.

Can we restore data across multiple regions using Azure Cosmos DB automatic backups?

Yes, Azure Cosmos DB’s automatic backup-restore feature allows restoring data across multiple regions for globally distributed apps.

How can one restore the data from the backup on Azure Cosmos DB?

For restoring any of your auto-taken backups, you need to raise a support request with Microsoft. Azure Cosmos DB team will restore the data for a requested point-in-time within the last 30 days.

What is the Azure Cosmos DB backup and restore feature?

The Azure Cosmos DB backup and restore feature automatically backs up data and offers support to restore the data to any point within the last 30 days.

How to enable continuous backup mode in Azure Cosmos DB?

Continuous backup mode can only be enabled at the account creation time via Azure portal, Azure Resource Manager templates, or SDKs that support APIs for continuous backup mode.

What is the main benefit of continuous backup mode in Azure Cosmos DB?

The main benefit of continuous backup mode is that it allows restoring data at any point in time (up to the last second) during the last 30 days, offering better granular control than periodic backup mode.

What is the retention period of backups in Azure Cosmos DB?

The retention period of backups in Azure Cosmos DB is thirty days.

How many copies of the data does Azure Cosmos DB maintain at any point of time?

Azure Cosmos DB maintains multiple copies of the data over geographically dispersed regions to ensure high availability and loss prevention during a regional outage. In terms of backups, the latest two backups are stored.

Leave a Reply

Your email address will not be published. Required fields are marked *