2.0 KiB
2.0 KiB
Strapi Migration Scripts
This directory contains scripts to migrate content from one Strapi server to another.
Prerequisites
- Node.js installed
- Access to both old and new Strapi servers
- API token for the new Strapi server (if authentication is required)
Setup
- Create a
.envfile in the project root (or set environment variables):
NEW_STRAPI_URL=https://your-new-strapi-server.com
NEW_STRAPI_API_TOKEN=your-api-token-here
Usage
Export Only
Export content from the old Strapi server:
node scripts/migrate-strapi.js export
This will create a strapi-export directory with JSON files containing all content.
Import Only
Import previously exported content to the new Strapi server:
node scripts/migrate-strapi.js import
Full Migration
Export and import in one command:
node scripts/migrate-strapi.js migrate
Content Types Migrated
The script migrates the following content types:
schoolforschools- Main hero section contentwhyschoolforschools- Why SFS section content
Notes
- The script handles Strapi v4 format by default
- Media files (images) are not automatically migrated - you'll need to manually upload them or use Strapi's media library migration tools
- Relations between content types may need manual adjustment after migration
- Always test the migration on a staging server first
Troubleshooting
Authentication Errors
If you get 401/403 errors, make sure:
NEW_STRAPI_API_TOKENis set correctly- The API token has proper permissions in Strapi
- The content type permissions allow creation via API
Missing Content
If some content doesn't migrate:
- Check the console output for specific errors
- Verify the content type names match exactly
- Ensure
populate=*is working on the source server
Media Files
Media files need separate handling:
- Export media files from old Strapi
- Upload to new Strapi media library
- Update media references in migrated content