Skip to content

Commit d5c8074

Browse files
pwizlainnerdvationsConvly
authored
Add transfer "pull" (from) to Data Management System documentation (#1604)
* Mark data transfer as new in the TOC * Fix formatting and consistency * Update intro sentences to account for transfer pull * Shorten tip about admin panel * Add `--from` parameter * Mention token type in user guide * Update screenshot in user guide to account for token type * Adapt content (minimal set of commands) to both --to and --from use cases * Fix: remote <> remote not allowed Co-authored-by: Ben Irvin <[email protected]> * Fix syntax: remote URL → remoteURL Co-authored-by: Ben Irvin <[email protected]> * Fix: can't edit duration * Fix wording: or → and/or Co-authored-by: Jean-Sébastien Herbaux <[email protected]> * Fix syntax: destination URL → destinationURL Co-authored-by: Ben Irvin <[email protected]> * Fix syntax: remote URL → remoteURL Co-authored-by: Ben Irvin <[email protected]> * Explicitly state one should use either --to or --from * Simplify wording in caution callout Co-authored-by: Ben Irvin <[email protected]> * Update docusaurus/docs/dev-docs/data-management/transfer.md * Update docusaurus/docs/dev-docs/data-management/transfer.md Co-authored-by: Ben Irvin <[email protected]> * Align prompt wording with commit 21ef0245790ab3350db9b2e2e677d3b626099253 * Align prompt wording with commit 21ef0245790ab3350db9b2e2e677d3b626099253 --------- Co-authored-by: Ben Irvin <[email protected]> Co-authored-by: Jean-Sébastien Herbaux <[email protected]>
1 parent e4bbc44 commit d5c8074

File tree

6 files changed

+103
-45
lines changed

6 files changed

+103
-45
lines changed

docusaurus/docs/dev-docs/cli.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,20 @@ strapi import -f your-filepath-and-filename --key my-key
168168
The destination Strapi instance should be running with the `start` command and not the `develop` command.
169169
:::
170170

171-
| Option | description | required |
172-
|------------------------------|------------------------------------------------------------------------------------------------------------------------------------|:-----------------:|
173-
| `--to` {destinationURL} | URL of the destination Strapi instance. Include the `/admin` endpoint. | required |
174-
| `--to-token` {transferToken} | Transfer token for the remote Strapi destination | required |
175-
| `--force` | Automatically answer "yes" to all prompts, including potentially destructive requests, and run non-interactively. | - |
176-
| `--exclude` | Exclude data using comma-separated data types. The available types are: `content`, `files`, and `config`. | - |
177-
| `--only` | Include only these data. The available types are: `content`, `files`, and `config`. | - |
178-
| `-h`, `--help` | Displays the commands for `strapi transfer`. | - |
171+
| Option | Description |
172+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
173+
| `--to [destinationURL]` | Full URL of the `/admin` endpoint on the destination Strapi instance<br />(e.g. `--to https://my-beautiful-strapi-website/admin`) |
174+
| `--to-token [transferToken]` | Transfer token for the remote Strapi destination |
175+
| `--from [sourceURL]` | Full URL of the `/admin` endpoint of the remote Strapi instance to pull data from<br />(e.g., `--from https://my-beautiful-strapi-website/admin`) |
176+
| `‑‑from‑token` | Transfer token from the Strapi source instance. |
177+
| `--force` | Automatically answer "yes" to all prompts, including potentially destructive requests, and run non-interactively. |
178+
| `--exclude` | Exclude data using comma-separated data types. The available types are: `content`, `files`, and `config`. |
179+
| `--only` | Include only these data. The available types are: `content`, `files`, and `config`. |
180+
| `-h`, `--help` | Displays the commands for `strapi transfer`. |
181+
182+
:::caution
183+
Either `--to` or `--from` is required, but it's not currently allowed to enter both or neither.
184+
:::
179185

180186
**Example**
181187

docusaurus/docs/dev-docs/data-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Occasionally, you need to move data out of or into a Strapi instance. This is po
1616

1717
- Use [`strapi export`](/dev-docs/data-management/export) to create a data backup, for archive purposes or to import it in another instance.
1818
- Use [`strapi import`](/dev-docs/data-management/import) to restore data from a backup.
19-
- Use [`strapi transfer`](/dev-docs/data-management/transfer) to transfer data from a local to a remote Strapi instance.
19+
- Use [`strapi transfer`](/dev-docs/data-management/transfer) to transfer data between local and/or remote instances.
2020

2121
The following documentation gives explanations and examples for the export, import, and transfer commands, while the [CLI reference documentation](/dev-docs/cli#strapi-export) lists all available flags in a condensed format.
2222

docusaurus/docs/dev-docs/data-management/transfer.md

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ canonicalUrl: https://docs.strapi.io/dev-docs/data-management/transfer.html
66
---
77
# Data transfer
88

9-
The `strapi transfer` command streams your data from one Strapi instance to another Strapi instance. The `transfer` command uses strict schema matching, meaning your two Strapi instances need to be exact copies of each other except for the contained data. The default `transfer` command transfers your content (entities and relations), files (assets), project configuration, and schemas. The command allows you to transfer data between:
9+
The `strapi transfer` command streams your data from one Strapi instance to another Strapi instance. The `transfer` command uses strict schema matching, meaning your two Strapi instances need to be exact copies of each other except for the contained data. The default `transfer` command transfers your content (entities and relations), files (assets), project configuration, and schemas. The command allows you to transfer data:
1010

11-
- a local Strapi instance and a remote Strapi instance,
12-
- a remote Strapi instance and another remote Strapi instance.
11+
- from a local Strapi instance to a remote Strapi instance
12+
- from a remote Strapi instance to a local Strapi instance
1313

1414
:::caution
1515

@@ -20,16 +20,22 @@ The `strapi transfer` command streams your data from one Strapi instance to anot
2020

2121
The CLI command consists of the following arguments:
2222

23-
| Option | Description | Required |
24-
|------------|--------------------------------------------------------------| :------: |
25-
| `--to` | Full URL of the `/admin` endpoint on the destination Strapi instance (e.g. `https://my-beautiful-strapi-website/admin`) | Yes |
26-
| `‑‑to‑token` | Transfer token from the Strapi destination instance. |No |
27-
| `--force` | Automatically answer "yes" to all prompts, including potentially destructive requests, and run non-interactively. |No |
28-
| `--exclude` | Exclude data using comma-separated data types. The available types are: `content`, `files`, and `config`. |No |
29-
| `--only` | Include only these data. The available types are: `content`, `files`, and `config`. |No |
23+
| Option | Description |
24+
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
25+
| `--to` | Full URL of the `/admin` endpoint on the destination Strapi instance<br />(e.g. `--to https://my-beautiful-strapi-website/admin`) |
26+
| `‑‑to‑token` | Transfer token from the Strapi destination instance. |
27+
| `--from` | Full URL of the `/admin` endpoint of the remote Strapi instance to pull data from (e.g., `--from https://my-beautiful-strapi-website/admin`) |
28+
| `‑‑from‑token` | Transfer token from the Strapi source instance. |
29+
| `--force` | Automatically answer "yes" to all prompts, including potentially destructive requests, and run non-interactively. |
30+
| `--exclude` | Exclude data using comma-separated data types. The available types are: `content`, `files`, and `config`. |
31+
| `--only` | Include only these data. The available types are: `content`, `files`, and `config`. |
32+
33+
:::caution
34+
Either `--to` or `--from` is required.
35+
:::
3036

3137
:::tip
32-
Data transfers are authorized by Transfer tokens, which are generated in the Admin panel. From the Admin panel you can manage role-based permissions to tokens including `view`, `create`, `read`, `regenerate` and `delete`. See the [User Guide](/user-docs/settings/managing-global-settings#creating-a-new-transfer-token) for details on how to create and manage Transfer tokens.
38+
Data transfers are authorized by transfer tokens, which are [managed from the admin panel](/user-docs/settings/managing-global-settings#managing-transfer-tokens). From the admin panel, you can manage role-based permissions to tokens including `view`, `create`, `read`, `regenerate` and `delete`.
3339
:::
3440

3541
## Generate a transfer token
@@ -38,42 +44,80 @@ Data transfers are authorized by Transfer tokens, which are generated in the Adm
3844
A salt transfer token should be defined in the [admin panel configuration](/dev-docs/configurations/admin-panel) file.
3945
:::
4046

41-
The `strapi transfer` command requires a Transfer token issued by the destination instance. To generate a Transfer token in the Admin panel use the instructions in the [User Guide](/user-docs/settings/managing-global-settings#creating-a-new-transfer-token).
47+
The `strapi transfer` command requires a transfer token issued by the destination instance. To generate a transfer token in the admin panel use the instructions in the [User Guide](/user-docs/settings/managing-global-settings#creating-a-new-transfer-token).
4248

4349
## Setup and run the data transfer
4450

45-
To initiate a data transfer:
51+
Initiating a data transfer depends on whether you want to push data to a remote instance or to pull data from the remote:
4652

47-
1. Start the Strapi server for the destination instance.
48-
2. In a new terminal window, navigate to the root directory of the source instance.
49-
3. Run the following minimal command to initiate the transfer:
53+
<Tabs>
5054

51-
<Tabs groupId="yarn-npm">
55+
<TabItem value="push" label="Push data to remote">
5256

53-
<TabItem value="yarn" label="yarn">
57+
1. Start the Strapi server for the destination instance.
58+
2. In a new terminal window, navigate to the root directory of the source instance.
59+
3. Run the following minimal command to initiate the transfer:
5460

55-
```bash
56-
yarn strapi transfer --to destination URL
57-
```
61+
<Tabs groupId="yarn-npm">
5862

59-
</TabItem>
63+
<TabItem value="yarn" label="yarn">
6064

61-
<TabItem value="npm" label="npm">
65+
```bash
66+
yarn strapi transfer --to destinationURL
67+
```
6268

63-
```bash
64-
npm run strapi transfer -- --to destination URL
65-
```
69+
</TabItem>
70+
71+
<TabItem value="npm" label="npm">
72+
73+
```bash
74+
npm run strapi transfer -- --to destinationURL
75+
```
76+
77+
</TabItem>
78+
79+
</Tabs>
80+
81+
4. Add the transfer token when prompted to do so.
82+
5. Answer **Yes** or **No** to the CLI prompt: "The transfer will delete all of the remote Strapi assets and its database. Are you sure you want to proceed?"
6683

6784
</TabItem>
6885

69-
</Tabs>
86+
<TabItem value="pull" label="Pull data from remote">
87+
88+
1. Start the Strapi server for the source instance.
89+
2. In a new terminal window, navigate to the root directory of the destination instance.
90+
3. Run the following minimal command to initiate the transfer:
91+
92+
<Tabs groupId="yarn-npm">
93+
94+
<TabItem value="yarn" label="yarn">
95+
96+
```bash
97+
yarn strapi transfer --from remoteURL
98+
```
7099

71-
4. Add the Transfer token when prompted to do so.
72-
5. Answer **Yes** or **No** to the CLI prompt: "The transfer will delete all data in the remote database and media files. Are you sure you want to proceed?"
100+
</TabItem>
101+
102+
<TabItem value="npm" label="npm">
103+
104+
```bash
105+
npm run strapi transfer -- --from remoteURL
106+
```
107+
108+
</TabItem>
109+
110+
</Tabs>
111+
112+
4. Add the transfer token when prompted to do so.
113+
5. Answer **Yes** or **No** to the CLI prompt: "The transfer will delete all of the local Strapi assets and its database. Are you sure you want to proceed?".
114+
115+
</TabItem>
116+
</Tabs>
73117

74118
## Bypass all `transfer` command line prompts
75119

76-
When using the `strapi transfer` command, you are required to confirm that the transfer will delete the existing database contents. The `--force` flag allows you to bypass this prompt. This option is useful for implementing `strapi transfer` programmatically. You must pass the `to-token` option with the Transfer token if you use the `--force` option.
120+
When using the `strapi transfer` command, you are required to confirm that the transfer will delete the existing database contents. The `--force` flag allows you to bypass this prompt. This option is useful for implementing `strapi transfer` programmatically. You must pass the `to-token` option with the transfer token if you use the `--force` option.
77121

78122
:::caution
79123
The `--force` option bypasses all warnings about content deletion.
@@ -159,7 +203,7 @@ Any types excluded from the transfer will be deleted in your destination instanc
159203
160204
## Manage data transfer with environment variables
161205
162-
The environment variable `STRAPI_DISABLE_REMOTE_DATA_TRANSFER` is available to disable remote data transfer. In addition to the [RBAC permissions](/user-docs/users-roles-permissions/configuring-administrator-roles#plugins-and-settings) in the Admin panel this can help you secure your Strapi application. To use `STRAPI_DISABLE_REMOTE_DATA_TRANSFER` you can add it to your `.env` file or preface the `start` script. See the following example:
206+
The environment variable `STRAPI_DISABLE_REMOTE_DATA_TRANSFER` is available to disable remote data transfer. In addition to the [RBAC permissions](/user-docs/users-roles-permissions/configuring-administrator-roles#plugins-and-settings) in the admin panel this can help you secure your Strapi application. To use `STRAPI_DISABLE_REMOTE_DATA_TRANSFER` you can add it to your `.env` file or preface the `start` script. See the following example:
163207
164208
```bash
165209
STRAPI_DISABLE_REMOTE_DATA_TRANSFER=true yarn start
@@ -230,7 +274,7 @@ npm run build && npm run start
230274
</Tabs>
231275
232276
2. Register an admin user.
233-
3. [Create and copy a Transfer token](/user-docs/settings/managing-global-settings#creating-a-new-transfer-token).
277+
3. [Create and copy a transfer token](/user-docs/settings/managing-global-settings#creating-a-new-transfer-token).
234278
4. Leave the server running.
235279
236280
### Transfer your data
@@ -258,7 +302,7 @@ npm run strapi transfer -- --to http://localhost:1337/admin
258302
259303
</Tabs>
260304
261-
3. When prompted, apply the Transfer token.
305+
3. When prompted, apply the transfer token.
262306
4. When the transfer is complete you can return to the second Strapi instance and see that the content is successfully transferred.
263307
264308
:::tip

docusaurus/docs/user-docs/settings/managing-global-settings.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ To regenerate an API token:
150150
* The *Global settings > Transfer Tokens* sub-section of the settings interface is accessible in the admin panel only if the _Transfer tokens > Read_ permission is granted.
151151
:::
152152

153-
Transfer tokens allow users to authorize the `strapi transfer` CLI command (see [Developer Documentation](/dev-docs/data-management#transfer)). Administrators can manage API tokens through the *Global settings > Transfer Tokens* sub-section of the settings interface.
153+
Transfer tokens allow users to authorize the `strapi transfer` CLI command (see [Developer Documentation](/dev-docs/data-management/transfer)). Administrators can manage API tokens through the *Global settings > Transfer Tokens* sub-section of the settings interface.
154154

155155
![Transfer tokens](/img/assets/settings/settings_transfer-token.png)
156156

157157
The *Transfer Tokens* settings sub-section displays a table listing all of the created Transfer tokens.
158158

159159
The table displays each Transfer token's name, description, date of creation, and date of last use. From the table, administrators can also:
160160

161-
- Click on the edit button <!-- icon --> to edit an Transfer token's name, description, type, duration or [regenerate the token](#regenerating-a-transfer-token).
161+
- Click on the edit button <!-- icon --> to edit a transfer token's name, description, or type, or [regenerate the token](#regenerating-a-transfer-token).
162162
- Click on the delete button <!-- icon --> to delete a Transfer token.
163163

164164
### Creating a new transfer token
@@ -173,6 +173,7 @@ To create a new Transfer token:
173173
| Name | Write the name of the Transfer token. |
174174
| Description | (optional) Write a description for the Transfer token. |
175175
| Token duration | Choose a token duration: *7 days*, *30 days*, *90 days*, or *Unlimited*. |
176+
| Token type | Choose a token type:<ul><li>*push* to allow transfers from local to remote instances only,</li><li>*pull* to allow transfers from remote to local instances only,</li><li>or *full access* to allow both types of transfer.</li></ul> |
176177

177178
3. Click on the **Save** button. The new Transfer token will be displayed at the top of the interface, along with a copy button <!-- icon -->.
178179

docusaurus/sidebars.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,14 @@ const sidebars = {
245245
items: [
246246
'dev-docs/data-management/export',
247247
'dev-docs/data-management/import',
248-
'dev-docs/data-management/transfer'
248+
{
249+
type: 'doc',
250+
label: 'Data transfer',
251+
id: 'dev-docs/data-management/transfer',
252+
customProps: {
253+
new: true,
254+
},
255+
}
249256
],
250257
},
251258
'dev-docs/database-migrations',
-1.11 MB
Loading

0 commit comments

Comments
 (0)