Dec 14th - Learn how Tecovas roped in success with Sanity and Shopify 🤠

How to retrieve a previous dataset in using the History API.

12 replies
Last updated: Jun 13, 2022
Hello,Does sanity keep dataset backups somewhere or is it something that needs to be done manually?
Is there a way to retrieve a dataset as of yesterday?

I have mistakenly overwritten the production dataset with the development one which is few months old, and I cannot find any option on the website to restore a previous dataset. (project is on team plan if that helps)

Jun 10, 2022, 9:07 AM
You’d have to do it manually with the export functionality I’m afraid. 😞
Jun 10, 2022, 9:16 AM
Maybe a support engineer can help you though.
Jun 10, 2022, 9:17 AM
Thanks User, how do I reach a support engineer?
Jun 10, 2022, 9:18 AM
Someone will reach out to you I guess.
Jun 10, 2022, 9:31 AM
Thanks 🙂 I'll wait
Jun 10, 2022, 9:32 AM
Hi User,This might be a case we cannot solve
😔. We generally recommend folks adopt their own backup routine; either by exporting their dataset or by making use of our cloud dataset cloning (for enterprise customers).However since you didn't delete the dataset in this case, it might be possible to rework it with information from the
History API if you feel comfortable writing a script. If you wish to explore that route, please let us know if we can assist in any way.
Jun 10, 2022, 5:46 PM
user J
, yep I've written sanity scripts before so I might get down to that route.
Does the history gets preserved even if I ran a restore with the
flag? From a quick check on the backend everything seem to be dated back to April, some documents even on February with the exception of new documents which have been preserved
Jun 10, 2022, 6:58 PM
Yes, history should be preserved via the transaction log.You can confirm this by running the command below, replacing these variables:

(obtained via
sanity debug --secrets
in the CLI)


of a document that was replaced)
curl -H "Authorization: Bearer &lt;AUTH_TOKEN&gt;" "https://&lt;PROJECT_ID&gt;.<|>/&lt;DATASET_NAME&gt;/transactions/&lt;DOCUMENT_ID&gt;?excludeContent=true"
Jun 13, 2022, 9:47 AM
omg, it works
Jun 13, 2022, 10:22 AM
Life saver! Thank you very much!!!
Jun 13, 2022, 10:22 AM
Jun 13, 2022, 10:45 AM
Wonderful we were able to help you out!
Jun 13, 2022, 10:46 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?