A powerful CLI tool to restore entire Storyblok CMS spaces from backup files created by storyblok-backup.
This tool handles the complete restoration process including dependency resolution, ID/UUID mapping, reference fixing, and intelligent conflict resolution across all Storyblok resource types.
- π Complete Space Restoration - Restore entire Storyblok spaces from backup folders
- π― Selective Resource Restoration - Choose specific resource types to restore
- π Dependency Resolution - Automatically handles resource dependencies and restoration order
- π ID/UUID Mapping - Manages cross-resource references and ID mappings
- β‘ Smart Conflict Resolution - Intelligent upsert logic (create-first, update-on-conflict)
- π Asset File Support - Restores both asset metadata and actual files
- π Verbose Logging - Detailed progress tracking and debugging information
- Node.js (v16 or higher)
- A Storyblok account with Management API access
- OAuth token from your Storyblok account settings
- Backup files created by storyblok-backup
npm install -g storyblok-restorenpm install storyblok-restorenpx storyblok-restorestoryblok-restore space-restore \
--backup-path ./backup \
--token YOUR_OAUTH_TOKEN \
--space YOUR_SPACE_IDYou can set credentials via environment variables:
export STORYBLOK_OAUTH_TOKEN="your_oauth_token"
export STORYBLOK_SPACE_ID="your_space_id"
export STORYBLOK_REGION="eu" # Optional: eu, us, ap, ca, cn
storyblok-restore space-restore --backup-path ./backup| Option | Description | Required |
|---|---|---|
--backup-path |
Path to the backup folder | β |
--token |
Storyblok OAuth token | β * |
--space |
Storyblok space ID | β * |
--region |
Region (eu, us, ap, ca, cn) | β |
--resource-types |
Comma-separated list of resource types | β |
--verbose |
Enable detailed logging | β |
*Required unless set via environment variables
# Restore all resources from backup
storyblok-restore space-restore \
--backup-path ./my-backup \
--token $STORYBLOK_OAUTH_TOKEN \
--space $STORYBLOK_SPACE_ID \
--verbose# Restore only specific resource types
storyblok-restore space-restore \
--backup-path ./my-backup \
--token $STORYBLOK_OAUTH_TOKEN \
--space $STORYBLOK_SPACE_ID \
--resource-types "stories,components,assets"# Restore to US region space
storyblok-restore space-restore \
--backup-path ./my-backup \
--token $STORYBLOK_OAUTH_TOKEN \
--space $STORYBLOK_SPACE_ID \
--region usThe tool can restore the following Storyblok resource types:
webhooks- Webhook configurations (secrets must be manually re-added)access-tokens- API access tokenscollaborators- Space collaborators and permissionscomponent-groups- Component organization groupscomponents- Reusable content componentsdatasources- External data sourcesdatasource-entries- Data source entries and contentasset-folders- Asset organization foldersassets- Media assets and filesstories- Content pages and entries
The tool expects backup folders created by storyblok-backup with this structure:
backup/
βββ space-{space_id}.json # Space configuration
βββ webhooks/ # Webhook configurations
β βββ *.json
βββ access-tokens/ # API access tokens
β βββ *.json
βββ collaborators/ # Space collaborators
β βββ *.json
βββ component-groups/ # Component groups
β βββ *.json
βββ components/ # Content components
β βββ *.json
βββ datasources/ # Data sources
β βββ *.json
βββ datasource-entries/ # Data source entries
β βββ *.json
βββ asset-folders/ # Asset folders
β βββ *.json
βββ assets/ # Asset metadata
β βββ *.json
βββ asset-files/ # Actual asset files
β βββ *.*
βββ stories/ # Content stories
βββ *.json
- Backup Analysis - Scans the backup folder structure and validates resources
- Dependency Resolution - Determines the correct restoration order based on resource dependencies
- Smart Restoration - Uses intelligent upsert logic:
- Attempts to create new resources (fast path for 99.9% of cases)
- Detects conflicts and automatically switches to update mode
- Finds existing resources and updates them with new data
- Reference Fixing - Updates cross-resource references and ID mappings
- Asset Handling - Uploads asset files and links them to asset metadata
- Progress Tracking - Provides detailed logging and error reporting
Create a .env file in your project root:
STORYBLOK_OAUTH_TOKEN=your_oauth_token_here
STORYBLOK_SPACE_ID=123456
STORYBLOK_REGION=eu- Use the
--verboseflag for detailed logging - Check that your backup structure matches the expected format
- Ensure all required dependencies are included in the backup
This tool is designed to work with backups created by storyblok-backup by @webflorist. Special thanks for creating the comprehensive backup solution that makes this restoration tool possible.
This project is licensed under the MIT License.
Contributions are welcome! Please see CONTRIBUTING.md for development setup and guidelines.