Skip to content

Instantly share code, notes, and snippets.

@mikaelvesavuori
Created October 30, 2023 06:05
Show Gist options
  • Save mikaelvesavuori/9c29316013859e3918e135ed26703d36 to your computer and use it in GitHub Desktop.
Save mikaelvesavuori/9c29316013859e3918e135ed26703d36 to your computer and use it in GitHub Desktop.
Import and export spaces in Contentful.
#!/bin/bash
# See: https://www.contentful.com/developers/docs/tutorials/cli/import-and-export/
EXPORT_FOLDER="export"
EXPORT_FILE="backup.json"
SPACE_ID="YOUR_ID_HERE"
mkdir -p $EXPORT_FOLDER
npx contentful-cli login
npx contentful-cli space use $SPACE_ID
npx contentful-cli space export \
--save-file \
--export-dir $EXPORT_FOLDER \
--content-file $EXPORT_FILE \
--download-assets \
--include-drafts
#!/bin/bash
# See: https://www.contentful.com/developers/docs/tutorials/cli/import-and-export/
EXPORT_FOLDER="export"
EXPORT_FILE="backup.json"
SPACE_ID="YOUR_ID_HERE"
mkdir -p $EXPORT_FOLDER
npx contentful-cli login
npx contentful-cli space use $SPACE_ID
npx contentful-cli space import --content-file $EXPORT_FOLDER/$EXPORT_FILE
#!/bin/bash
npm install -D contentful-cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment