How to restore entire dataset to previous date or undo recent changes?

6 replies
Last updated: Jan 28, 2026
Is there a way to restore an entire dataset to what it was on a previous date or undo the most recent change on all documents? Asking for a friend... 😬
AI Update

😬 I feel your friend's pain! Unfortunately, Sanity doesn't have a built-in way to do a full dataset rollback to a previous date or bulk-undo across all documents.

What Sanity DOES offer:

Document History lets you restore documents one at a time by viewing their revision history and rolling back to a previous version. You can access this through the document status indicator at the bottom of the editor or via the contextual menu (ellipsis icon) → "History".

Important limitations:

  • Retention periods vary by plan:
    • Free: 3 days
    • Growth: 90 days
    • Enterprise: 365 days (customizable)
  • After the retention period, older revisions are permanently deleted (though the latest published/draft versions remain)

For bulk restoration:

If your friend needs to restore multiple documents, they'd need to use the History API programmatically. You could:

  1. Query the history for each document
  2. Retrieve the revision from your target date (using the _rev property)
  3. Use the JavaScript client's createOrReplace() method to restore each document

This would essentially be a custom script to loop through documents and restore them individually. Not ideal, but it's the available path.

Prevention tip: For future peace of mind, consider exporting dataset backups regularly using the sanity dataset export CLI command. That way you have a safety net outside of the built-in history retention!

Show original thread
6 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?