Today, I will demonstrate migrating or switching the backup policy from periodic to the continuous backup policy of an existing Azure Cosmos DB account. I have explained Cosmos DB backup policies in my last few articles which are given below for your reference to understand the topics.
- Understanding Azure Cosmos DB backup options
- How to configure Periodic backup for a cosmos DB account
- How to configure Continuous backup for a Cosmos DB account
Azure Cosmos DB offers two policies, one is the periodic backup and another one is the continuous backup policy. Periodic backup mode is the default configuration for Azure Cosmos DB accounts which runs on regularly defined intervals. You need to create a support ticket for the Azure support team to restore or recover any data. Continuous backup is the other option that supports only MongoDB and core (SQL) APIs. You don’t need to create any support ticket to recover your data if you have configured continuous backup.
The main benefit of having a continuous backup is you can recover point in time data till the last 30 days and you don’t need to depend on the Azure support team for data restorations. You will also have local backup copies in each region where you have globally distributed your data, this will give you confidence from a data protection standpoint.
Before migrating your periodic backup policy to a continuous backup policy, you must be aware that this is one-way activity, and you cannot switch it back to the periodic backup policy once you will initiate this migration to continuous backup so I would recommend you plan carefully and consider all aspects from pricing, recoverability, compatibility, and availability of backup copies. I would suggest first doing it for a lower life cycle environment or doing a POC to understand its functionalities and then deploying it in production once you will have full confidence in this feature.
You should consider the below points while deciding to switch over to continuous backup as it has many limitations, and this migration is a bit time-consuming.
- Pricing as each region will have their backup copies
- You cannot roll back or reverse this migration, so the only option left is to migrate the backup policy to continuous backup even in case of migration failure. You must keep on trying to enable continuous backup as you cannot switch back to periodic backup once you have initiated the migration. Even you cannot cancel this migration.
- Continuous backup works only for SQL and MongoDB APIs
- It does not support multi-region writes, customer-managed keys for encryption, and analytical store
- The migration process will take time-based on the data size and a number of regions you have for your account. If you have a few TBs of data with multiple regions, then it can take days as per MSDN documentation.
- Data restore points will not be available using either of the backup modes during the migration process. It means you can recover your data till the point you initiate the migration and after the point, you successfully migrated the backup policy to continuous backup.
- You cannot perform some account-level operations like adding or removing regions, throughput updates, failovers, etc. so be aware of this as well.
Considering the above points, I would suggest you choose the right time frame to execute this migration.
Migrate periodic backup to the continuous backup policy
I have divided this demonstration into the below 3 sections.
- Create an Azure Cosmos DB account with a periodic backup policy
- Migrate periodic backup to continuous backup for the above newly created account
Let’s understand all prerequisites which must be met for continuous backup.
You must verify the below points as part of the prerequisites to ensure your Azure Cosmos DB account is qualified for this migration.
- Make sure you have understood migration timings which I explained above and you are also aware of data restore points and some account level operations that cannot be supported during the migration process.
- Account must have either SQL or MongoDB API type
- The account is not enabled for multi-region writes and should run with single region writes
- The account is not configured to use customer-managed keys for encryption and with not enabled with the analytical store.
Azure Cosmos DB account creation
I have provisioned a cosmos DB account with MongoDB type API. I am not describing each step for provisioning an Azure Cosmos DB account in this section. I filled in the required details and left all settings with default options; a periodic backup policy is also configured as part of the default configuration as shown in the below image. The validation process has been successfully passed, now hit the Create button to start this deployment.
Let me verify that the backup policy for the above newly created account is set to periodic and continuous backup is turned off.
We can see the Backup & Restore tab is showing under Settings which indicates that periodic backup is configured. We know the Backup & Restore tab will be disappeared in case of continuous backup and another tab will appear for it i.e. Point in Time Restore. The below image is also showing that continuous backup is set to Off for this cosmos DB account.
Now we have an Azure Cosmos DB account mongocosmosdb with a periodic backup policy, we need to migrate the backup policy for this account to continuous backup. Let’s do it in the next section in a step-by-step manner.
Migrate periodic backup to continuous backup
This section will show you how to migrate periodic backup to a continuous backup policy. Log in to the Azure portal and access your desired Azure Cosmos DB account for which you want to migrate its backup policy to continuous mode. Click at the Features tab given under Settings to check and access continuous backup status as it is showing in the above image. Now click on the Continuous Backup option given in the right side pane from the above image, another window will appear on your screen to enable this backup as shown in the below image.
Click the Enable button shown in the above image to initiate the migration. This migration process is time-consuming, and you must plan it during off-business hours because you will not be able to perform some account-level activities during the migration process like adding or removing regions, throughput change, or failover. Although there will not be any impact on the database availability and Azure Cosmos DB account will be serving client requests. The migration process will take more time if you have bigger databases with multiple regions.
I assume you have decided to go with this backup policy to adopt point in time recovery feature so let’s go ahead and hit the Enable button. The deployment will be initiated as shown in the small popup window in the top right corner of the below image.
The screen will keep on refreshing itself while changing the values to Pending status as shown in the below image. Let it be, don’t do anything on this screen.
The screen will perform several refreshes with showing all status as Pending in the greyed-out screen as shown in the below image.
Once Continuous backup will be successfully set to On then the screen will be enabled in editable mode. Have a look at the below image where the notification says continuous backup has been enabled and immediately greyed out screen is disappeared. You might also notice one thing the Backup & Restore tab showing in the left side pane of the below image is still showing even after enabling continuous backup. This should be gone, and another tab Point in Time Restore which is for continuous backup must be appearing. This is a ghost entry and will be disappeared after refreshing the page.
Here, I have refreshed the above screen and now you can see the Backup & Restore tab is not there under Settings and another tab Point in Time Restore is showing which is for continuous backup.
Now, you have successfully migrated the backup policy for your SQL or MongoDB API-based Cosmos DB account from its default value periodic backup to continuous backup to leverage its point-in-time restores.
This article has explained how to migrate the backup policy of an Azure Cosmos DB account that is using SQL or MongoDB API. This migration is a one-way activity and cannot be rolled back to its previous backup policy so you have also learned about points you must consider before migrating the backup policy to continuous backup.
- Difference between SQL SELECT UNIQUE and SELECT DISTINCT - January 16, 2024
- How to do a group by clause - April 12, 2023
- PostgreSQL vs MySQL: Understanding their differences - March 13, 2023