Skip to main content

Test a data transfer locally

Page summary:

A fully-worked example of the strapi transfer workflow 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

  1. Create a new Strapi project using the installation command:

    terminal
    npx create-strapi-app@latest <project-name> --quickstart
  2. Create at least 1 content type in the project. See the Quick Start Guide if you need instructions on creating your first content type.

    Caution

    Do not add any data to your project at this step.

  3. Commit the project to a git repository:

    terminal
    git init
    git add .
    git commit -m "first commit"
  4. Clone the project repository:

    terminal
    cd .. # move to the parent directory
    git clone <path to created git repository>.git/ <new-instance-name>
  5. Move into the cloned project and install its dependencies:

terminal
cd <new-instance-name>
yarn 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

  1. Return to the first Strapi instance and add data to the content type.
  2. Stop the server on the first instance.

Create a transfer token

  1. Navigate to the second Strapi instance and run the build and start commands in the root directory:
terminal
yarn build && yarn start
  1. Register an admin user.
  2. Create and copy a transfer token.
  3. Leave the server running.

Transfer your data

  1. Return to the first Strapi instance.
  2. In the terminal run the strapi transfer command:
terminal
yarn strapi transfer --to http://localhost:1337/admin
  1. When prompted, apply the transfer token.
  2. When the transfer is complete you can return to the second Strapi instance and see that the content is successfully transferred.
Tip

In some cases you might receive a connection refused error targeting localhost. Try changing the address to http://127.0.0.1:1337/admin.

Was this page helpful?