sb-mig
Reference

sync

Sync schemas, roles, datasources, plugins, stories, and assets.

sync

sb-mig sync <resource> [selector] [options]

sync pushes local schema-like resources to Storyblok or moves content between spaces/files. The supported resources are components, roles, datasources, plugins, and content.

components

Valid forms

sb-mig sync components --all
sb-mig sync components --all --dry-run
sb-mig sync components --all --presets
sb-mig sync components --all --presets --dry-run
sb-mig sync components --all --ssot --yes
sb-mig sync components --all --ssot --presets --yes
sb-mig sync components --all --ssot --dry-run
sb-mig sync components accordion accordion-item
sb-mig sync components accordion accordion-item --presets
sb-mig sync components accordion --packageName @scope/package
sb-mig sync components accordion --dry-run

Options

FlagTypeEffect
--allbooleanSync every discovered local component schema.
component namespositionalSync only the named local component schemas.
--presetsbooleanAlso sync component presets and set default presets.
--ssotbooleanSingle Source of Truth mode for --all; removes GUI-only remote components and replaces them with code versions.
--packageNamestringResolve provided components from an external package.
--dry-runbooleanPreview component changes without Storyblok writes.
--yesbooleanSkip the --ssot confirmation prompt.

--ssot is destructive and only applies with --all. Use --dry-run first.

roles

Valid forms

sb-mig sync roles --all
sb-mig sync roles --all --dry-run
sb-mig sync roles admin editor
sb-mig sync roles admin editor --dry-run

Options

FlagTypeEffect
--allbooleanSync every discovered local role schema.
role namespositionalSync only the named local role schemas.
--dry-runbooleanPreview role changes without Storyblok writes.

datasources

Valid forms

sb-mig sync datasources --all
sb-mig sync datasources --all --dry-run
sb-mig sync datasources countries cities
sb-mig sync datasources countries cities --dry-run

Options

FlagTypeEffect
--allbooleanSync every discovered local datasource schema.
datasource namespositionalSync only the named datasource schemas.
--dry-runbooleanPreview datasource changes without Storyblok writes.

plugins

Valid forms

sb-mig sync plugins my-awesome-plugin
sb-mig sync plugins my-awesome-plugin --dry-run

Run this from a plugin folder that exposes ./dist/export.js.

Options

FlagTypeEffect
plugin namespositionalSync the named plugins.
--dry-runbooleanPreview plugin sync without Storyblok writes.

sync plugins --all is not implemented. Pass explicit plugin names.

content

sb-mig sync content (--all | --stories | --assets) \
  --from <source> \
  --to <target> \
  --syncDirection <direction>

Selectors

SelectorEffect
--allSync stories and assets.
--storiesSync only stories.
--assetsSync only assets.

Shared options

FlagTypeEffect
--fromstringSource space ID or local story file name, depending on direction.
--tostringTarget space ID or local output file name, depending on direction.
--syncDirectionenumOne of fromSpaceToFile, fromFileToSpace, fromSpaceToSpace, fromAWSToSpace.
--dry-runbooleanPreview supported story/asset sync work without writes.
--yesbooleanSkip destructive target-story deletion prompts.

Directions

DirectionStory behaviorAsset behaviorNotes
fromSpaceToFileReads source space stories and writes local story files.Reads source space assets and writes local asset backup files.No target story deletion.
fromFileToSpaceReads local story file and writes stories into target space.Assets are not implemented for this direction.For stories, non-dry runs prompt, back up target stories, delete target stories, then write.
fromSpaceToSpaceReads source space stories and writes into target space.Reads source assets and writes into target space.Non-dry runs prompt, back up target stories, delete target stories, then write.
fromAWSToSpaceReads Content Hub/AWS data and writes stories into target space.Unsupported asset directions log not implemented.Intended for Content Hub import flows.

Common examples

Back up stories and assets to files:

sb-mig sync content --all \
  --from 12345 \
  --to prod-backup \
  --syncDirection fromSpaceToFile

Back up only stories:

sb-mig sync content --stories \
  --from 12345 \
  --to prod-stories-backup \
  --syncDirection fromSpaceToFile

Preview file-to-space story restore:

sb-mig sync content --stories \
  --from prod-stories-backup \
  --to 67890 \
  --syncDirection fromFileToSpace \
  --dry-run

Copy one space into another:

sb-mig sync content --all \
  --from 12345 \
  --to 67890 \
  --syncDirection fromSpaceToSpace \
  --yes

For destructive non-dry content syncs, sb-mig first writes a target story backup named from the target space, deletes target stories, then recreates stories.

On this page