Amazon DocumentDB - Item Level Recovery

0

Hi All,

is it possible item level recovery in document db, i don't see options in console. we have only taking backup and restore cluster , instance from snapshot. Could someone please help on this, how we can do the item level recovery in document db (i.e, missing collections or tables or indexs)

Thanks, Bhargav.

  • please accept the answer if it was useful

已提問 6 個月前檢視次數 238 次
1 個回答
0

Amazon DocumentDB does not provide built-in item-level recovery directly through the console. However, you can achieve item-level recovery using the following approaches:

1. Point-in-Time Restore (PITR) and Manual Extraction

Restore a Cluster to a Point in Time:

  • Use the DocumentDB console or AWS CLI to restore your cluster to a point in time before the item(s) were deleted.
  • This creates a new cluster with the data as it existed at the specified time.

Extract the Needed Data:

  • Connect to the new cluster and manually extract the items, collections, tables, or indexes that you need.
  • Use MongoDB tools like mongodump and mongorestore to transfer the required data back to your original cluster.

2. Use of Change Streams for Tracking and Recovery

  • If you have enabled change streams on your collections, you can use them to track changes to the data in real-time.
  • This allows you to capture deletions and modifications, making it possible to manually reconstruct the data if needed.

3. Custom Backup and Restore Logic

  • Implement custom logic to periodically back up critical collections or documents at the application level.
  • Store these backups in S3 or another storage service, allowing you to restore individual items when necessary.

Example of Restoring Using PITR

Here's a step-by-step example of how to restore a collection from a snapshot:

aws docdb restore-db-cluster-to-point-in-time \
    --source-db-cluster-identifier my-cluster \
    --target-db-cluster-identifier my-cluster-restore \
    --restore-to-time 2023-06-01T12:00:00Z

Connect to the Restored Cluster:

Use your MongoDB client or tools like mongosh to connect to the newly restored cluster.

Extract the Required Data:

mongodump --uri mongodb://restored-cluster-endpoint:27017 --db your_db --collection your_collection --out /path/to/dump

Restore the Data to the Original Cluster:

mongorestore --uri mongodb://original-cluster-endpoint:27017 --db your_db --collection your_collection /path/to/dump/your_db/your_collection.bson

Summary While Amazon DocumentDB does not support direct item-level recovery, using point-in-time restores, change streams, and custom backup logic allows you to achieve the same goal. For critical applications, consider implementing a comprehensive backup strategy to minimize data loss and facilitate recovery.

profile picture
專家
已回答 6 個月前
profile picture
專家
已審閱 6 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南