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

Discussion on backing up Sanity data for projects, including using CRON jobs and GitHub Actions.

16 replies
Last updated: May 27, 2020
Hey guys! Curious, what steps is everyone here taking to make sure their Sanity data is backed up, in case of some unfortunate accident?
May 27, 2020, 6:01 PM
I made two small projects with Sanity for clients and I didn't set a backup a routine. I only use one dataset and I don't see how it could happen that I delete the production dataset by mistake.But for big projects using several datasets, it could be good to have a backup routine in place to sleep better a night
馃槃 But then you should definitely charge the client for implementing that service.For a hobby project, I set up a CRON job that triggers a serverless function which backs up the dataset to Google Drive.

https://dev.to/mornir/create-a-service-account-to-authenticate-with-google-5b1k Dropbox is also an option.
May 27, 2020, 6:35 PM
For the CRON job I use GitHub Actions. For the severless function I use Netlify Functions.But I think that it should be possible to use GitHub Actions for the whole process! Even for storing the backups (as artifacts).
May 27, 2020, 6:40 PM
馃く this looks fascinating
J茅r么me Pott
. It's a new world for me, haven't dealt with cronjobs or cloud functions yet but expected that this task would take me down this path.
May 27, 2020, 6:41 PM
May 27, 2020, 6:42 PM
So wait, you did this for a hobby project but not a client one? Is this because of an abundance of trust in nothing going wrong sanity-side with your data?
May 27, 2020, 6:43 PM
Sanity keeps daily backups of all your content for 30 days. If something goes wrong on their side, they can restore the data.On my end, as a developer, I don't see how I would type "sanity delete dataset production" by mistake.
It's true that documents deleted by the client are gone forever. But he can still undo the deletion right after or copy from the production website before triggering a rebuild (for
jamstack websites). For some projects I just disable the delete option for some document types.And again: we're talking about websites with less than 10 pages.
May 27, 2020, 6:53 PM
When I found the time and the motivation to look more into GitHub Action, I'll try to set up a backup routine for every repo with a Sanity Studio.So the backups files would be stored right along the code
May 27, 2020, 6:55 PM
Ahh, you're right the daily backups for 30 days is probably enough to sleep safely at night. Still, going to look into doing some backups, to learn how to do it if nothing else 馃檪
May 27, 2020, 6:55 PM
J茅r么me Pott
stored along with the code? you mean you'd back-up the data to the repo? Isn't that going to bloat it too much?
May 27, 2020, 6:55 PM
yeah, especially if you backup several times a day and have a lot of assets
May 27, 2020, 6:56 PM
I also wonder what is GitHub pricing for storing artefacts. certainly not as cheap as Google Drive
May 27, 2020, 6:58 PM
Artifacts are a thing that becomes relevant once using actions right? Haven't dealt with them at all yet either
May 27, 2020, 6:59 PM
yeah, better to have your own backups. Sanity internal backups are not meant for cases when you're the one who screwed up馃槅But maybe in the future, we'll have a tab in Sanity management dashboard to view and manage their backups
May 27, 2020, 7:01 PM
Yes, that's right. From what I read, artifacts are the data/files generated by an Action.
May 27, 2020, 7:02 PM
oh, you can't manage sanity's backups. That too is a good thing to keep in mind. Thanks again
J茅r么me Pott
May 27, 2020, 7:03 PM
you're welcome. I was asking myself the same questions when first working with Sanity.
May 27, 2020, 7:04 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?