- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
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
andmongorestore
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.
Contenuto pertinente
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 3 anni fa
- AWS UFFICIALEAggiornata 2 mesi fa
please accept the answer if it was useful