I'm experiencing an issue with Azure CosmosDB point-in-time restore feature where documents with a short TTL seem unrecoverable. Let's say I have documents with a time to live (TTL) of 10 minutes. If I restore a backup from last week, the TTL is well past expired. Then those expired documents are deleted very soon after the backup is restored and the data I tried to recover is lost.
I'd expect it to work by Azure setting the timestamp property _ts
to the time of the restore (that default property is intended to represent the last-updated time of the document). Having it set to the time of the database restore would then reset the TTL, giving a chance to access the data. This expected behavior seems confirmed by a Microsoft Forum post
When importing a backup of a Cosmos DB database, the _ts (timestamp) fields are automatically updated to the current timestamp during the restore process.
However, my own experience is showing the _ts
property as not updated by Azure at the time of the restore. I can't find any more info on that detail in the official documentation.
So what's the correct way to restore data having a short TTL? Am I missing some necessary restore configuration, is this a bug, or is it just not supported?
Additional details:
Unfortunately there is no way to do this. This design decision is documented among the current limitations
it's possible that the data restored is deleted immediately if you configured that way
Hopefully at some point they will improve this - e.g. maybe provide an option to allow the restored backup to be restored in a state with the TTL cleanup disabled.
In the meantime I guess the best that you can do is go and turn off the TTL feature on the collection immediately the restored backup becomes available and hope that you were fast enough!
The forum thread you link is not about the built in back up and restore. They are "storing the backup as JSON in an azure storage account" - which is not how the backup options in the product work. So they must be talking about some export process that they are calling a backup. And where the "restore" is just doing an insert of every document to a new collection