Merging original Cosmos DB data with the restored data from continuous backup

Khushaal Kurswani 40 Reputation points Microsoft Vendor
2024-11-14T00:06:14.8333333+00:00

Cosmos DB's continuous backup allows for point of time restore where a backed-up version of the database can be restored to a new Cosmos DB account.

In the scenario, that some data is accidentally deleted from a Cosmos DB container, a back up can be restored in order to get back the deleted data.

However, this data would be restored in a new Cosmos DB account instead of the original one. In addition, there might be some newly inserted data in the original DB which is not part of the restored data.

Is there a way to transfer the restored data from the new Cosmos DB account to the original account without losing the new data inserted into the original account after the backup was taken?

There were some suggestions of using Azure Data Factory or the Cosmos DB change feed. But there is no documentation regarding the process for doing that.

What is the best way to merge the data from the original Cosmos DB and the new Cosmos DB created during the restore and what are the steps to achieve that?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,681 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ShaktiSingh-MSFT 15,766 Reputation points
    2024-11-14T09:26:45.0833333+00:00

    Hi Khushaal Kurswani •,

    Welcome to Micrsoft Q&A forum.

    As I understand, you want to merge original Cosmos DB data with the restored data from continuous backup.

    You could do so using Azure Data Factory.

    Create Linked Service to both the main and restored Cosmos DB Account.

    Create Data Pipeline using Data Flow transformations needed as per your requirement to filter records to avoid overwriting.

    Set up incremental load handle changes and avoid re-copying existing records.

    Helpful reference links:

    https://learn.microsoft.com/en-us/azure/data-factory/connector-azure-cosmos-db?tabs=data-factory

    https://learn.microsoft.com/en-us/azure/data-factory/tutorial-incremental-copy-overview

    https://www.youtube.com/watch?v=q6eqH22SGBE

    You may try to create your own custom function and achieve this task.

    Let us know if you have further queries in this or while implementation of ADF pipeline.

    Thanks

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.