diff --git a/README.md b/README.md index 62cffcf..ae67521 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1344 TILs and counting..._ +_1345 TILs and counting..._ --- @@ -1551,6 +1551,7 @@ _1344 TILs and counting..._ - [Change Window Name In iTerm](workflow/change-window-name-in-iterm.md) - [Convert An ePub Document To PDF On Mac](workflow/convert-an-epub-document-to-pdf-on-mac.md) +- [Create A Local Sanity Dataset Backup](workflow/create-a-local-sanity-dataset-backup.md) - [Create A Public URL For A Local Server](workflow/create-a-public-url-for-a-local-server.md) - [Enable Dev Tools For Safari](workflow/enable-dev-tools-for-safari.md) - [Forward Stripe Events To Local Server](workflow/forward-stripe-events-to-local-server.md) diff --git a/workflow/create-a-local-sanity-dataset-backup.md b/workflow/create-a-local-sanity-dataset-backup.md new file mode 100644 index 0000000..5fae71d --- /dev/null +++ b/workflow/create-a-local-sanity-dataset-backup.md @@ -0,0 +1,28 @@ +# Create A Local Sanity Dataset Backup + +Let's say you've put together a script that is going to mutate some data in +your production dataset on Sanity. Before you run that script, it would be +prudent to capture a backup in case something goes wrong. That way you can +always restore to how the data was in the event that you need to. + +You can do this from the command line with the `sanity` CLI. + +First, ensure you are signed in via the CLI. + +```bash +$ sanity login +``` + +Then, you can issue the `dataset export` command, naming the dataset (in this +case, `production`) to target and the name of the backup file to be created +locally. + +```bash +$ sanity dataset export production my-project-backup.tar.gz +``` + +I believe the Sanity CLI goes off the `sanity.cli.{ts,js}` file in your local +project directory to determine what Sanity project it should be working with. + +See the [`export dataset`](https://www.sanity.io/docs/dataset#fd38ca03b011) +docs for more details.