Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Best practices for backing up and restoring datasets in Sanity.io

6 replies
Last updated: Apr 29, 2021
Sanity datasets and backup
• Whats the best way to backup a dataset in Sanity?
• Can I do it from the dashboard?
• How about automatic scheduled backups? Like say once a week?
• How do I restore from an backup?
• Can I backup a dataset called
and create a new datasett called
based on the
Apr 29, 2021, 2:20 PM
sanity dataset export
from the CLI or using the
http api https://www.sanity.io/docs/export 2. I do not believe so
3. You could write a script that runs either of the above commands, but per my knowledge there is no automation other than what you build yourself
sanity dataset import
is the easiest way. You can also use a client library, though that has some pitfalls: https://www.sanity.io/docs/importing-data 5. Yes. Run
sanity dataset export production
which by default will be saved to a file called
. Then you run
sanity dataset import production.tar.gz development
and this will create a new dataset named
if one doesnt exist. If one does exist it will merge the two datasets. For more details look into the flags available on
sanity help dataset import
Apr 29, 2021, 2:32 PM
• Will the
sanity dataset export
command give me all data, including assets like images and files thats uploaded in the dataset?• What about the schema, is that a part of the export?
• Does that mean that I have to find some external cloud service to store my backups?
Apr 29, 2021, 2:35 PM
1. the export will include all user-generated documents, images and files, but will not include system documents that Sanity itself uses to function like custom access control ( https://www.sanity.io/docs/access-control#ce4a077926aa ) to my knowledge. 2. The schema isnt part of the dataset in the strictest sense. The schema is a concept that lives in the Studio and is how your Studio filters what documents are allowed to enter your dataset. Since it isnt part of the dataset it will therefore not be included in the export
a. Sidenote: Since only the Studio enforces your schema, you could also sidestep it by creating documents with the API or CLI that dont follow the schema. Be aware of this when creating documents this way
3. Yes, or some equivalent service according to your risk profile and data processor agreement
Apr 29, 2021, 2:43 PM
If I export
and then import it as
, do I then also have to do a graphql-deploy against my new
datasett for Gatsby and Sanity Studio to work agains the new
Apr 29, 2021, 2:46 PM
I dont know, I dont use graphql in my projects. 🙂 I would guess so, but you should try and see what needs to happen. You could also see if there is some information here that is helpful: https://www.sanity.io/docs/cli-graphql
Apr 29, 2021, 2:50 PM
Thank you! I will try 🙂
Apr 29, 2021, 2:54 PM

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?