Test a data transfer locally
Page summary:A fully-worked example of the
strapi transferworkflow between two local Strapi instances, to get familiar with the command before using it against a remote instance.
The transfer command is not intended for transferring data between two local instances. The export and import commands were designed for this purpose. However, you might want to test transfer locally on test instances to better understand the functionality before using it with a remote instance. The following documentation provides a fully-worked example of the transfer process.
Create and clone a new Strapi project
-
Create a new Strapi project using the installation command:
npx create-strapi-app@latest <project-name> --quickstart -
Create at least 1 content type in the project. See the Quick Start Guide if you need instructions on creating your first content type.
CautionDo not add any data to your project at this step.
-
Commit the project to a git repository:
git init
git add .
git commit -m "first commit" -
Clone the project repository:
cd .. # move to the parent directory
git clone <path to created git repository>.git/ <new-instance-name> -
Move into the cloned project and install its dependencies:
- yarn
- npm
cd <new-instance-name>
yarn install
cd <new-instance-name>
npm install
Without this step, the next build and start commands fail because strapi is not yet on the project's local executable path.
Add data to the first Strapi instance
- Return to the first Strapi instance and add data to the content type.
- Stop the server on the first instance.
Create a transfer token
- Navigate to the second Strapi instance and run the
buildandstartcommands in the root directory:
- yarn
- npm
yarn build && yarn start
npm run build && npm run start
- Register an admin user.
- Create and copy a transfer token.
- Leave the server running.
Transfer your data
- Return to the first Strapi instance.
- In the terminal run the
strapi transfercommand:
- yarn
- npm
yarn strapi transfer --to http://localhost:1337/admin
npm run strapi transfer -- --to http://localhost:1337/admin
- When prompted, apply the transfer token.
- When the transfer is complete you can return to the second Strapi instance and see that the content is successfully transferred.
In some cases you might receive a connection refused error targeting localhost. Try changing the address to http://127.0.0.1:1337/admin.