What steps are you taking to backup your Sanity data?

16 replies
Last updated: Nov 29, 2025
Hey guys! Curious, what steps is everyone here taking to make sure their Sanity data is backed up, in case of some unfortunate accident?
AI Update

Great question! Dataset backups are definitely something you should have a strategy for. Here's what the community typically does:

Using the CLI Export Command

The most common approach is using the Sanity CLI's export command. It's straightforward and gives you complete control:

sanity dataset export production

This creates a production.tar.gz file containing all your documents and assets. You can specify a custom filename/location too:

sanity dataset export production ./backups/backup-2024-01-15.tar.gz

The export includes everything - all documents, assets (images/files), and hidden configuration documents used by Studio and plugins. What it doesn't include is your schema definition (that lives in your code) or system-level documents.

Options Worth Knowing

By default, exports are compressed as .tar.gz archives with assets included. The CLI command sanity dataset export automatically includes assets and compresses the output. If you only need documents without assets, you can export to NDJSON format, though the standard tar.gz approach is recommended for complete backups since it contains both the NDJSON data stream and your asset files in separate folders.

Automated Backup Strategies

For production sites, manual exports aren't ideal. Here are common automation approaches:

GitHub Actions: You can set up automated backups using GitHub Actions that run on a schedule and store exports as artifacts or push them to cloud storage.

CI/CD Pipelines: Many folks integrate exports into their deployment pipelines, especially before running content migrations.

Scheduled Scripts: Write a simple script that runs sanity dataset export and uploads the result to S3, Google Cloud Storage, or your preferred backup service.

Before Migrations

One critical practice: always export before running content migrations:

sanity dataset export production backup-before-migration.tar.gz
sanity migration run your-migration

If something goes wrong, you can restore with:

sanity dataset import backup-before-migration.tar.gz production

Enterprise Options

If you're on an Enterprise plan, there are managed options:

  • Backups feature: Managed backups with retention policies handled by Sanity
  • Cloud Clone: Server-side dataset duplication without downloading data locally

Storage Considerations

Important note: Sanity doesn't provide built-in backup storage, so you'll need to handle that yourself. Store your exports in cloud storage services with appropriate retention policies for your compliance needs.

The combination of regular automated exports to external storage plus pre-migration backups covers most disaster recovery scenarios pretty well!

Show original thread
16 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?