数据传输
¥Data transfer
strapi transfer
命令是 数据管理功能 的一部分,将你的数据从一个 Strapi 实例传输到另一个 Strapi 实例。transfer
命令使用严格的模式匹配,这意味着你的两个 Strapi 实例需要是彼此的精确副本(除了所包含的数据之外)。默认 transfer
命令传输你的内容(实体和关系)、文件(资源)、项目配置和模式。该命令允许你传输数据:
¥The strapi transfer
command is part of the Data Management feature and 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:
-
从本地 Strapi 实例到远程 Strapi 实例
¥from a local Strapi instance to a remote Strapi instance
-
从远程 Strapi 实例到本地 Strapi 实例
¥from a remote Strapi instance to a local Strapi instance
以下文档详细介绍了自定义数据传输的可用选项。传输命令和所有可用选项均使用 Strapi CLI 运行。
¥The following documentation details the available options to customize your data transfer. The transfer command and all of the available options are run using the Strapi CLI.
-
如果你在目标实例中使用 SQLite 数据库,则在
transfer
操作运行时其他数据库连接将被阻止。¥If you are using an SQLite database in the destination instance other database connections will be blocked while the
transfer
operation is running. -
管理员用户和 API 令牌不会转移。
¥Admin users and API tokens are not transferred.
-
如果你的项目中使用了 websockets 或 Socket.io,传输命令将会失败。你需要暂时禁用 websockets 或 Socket.io,或者确保你的 websocket 服务器运行在与 Strapi 服务器不同的端口上,或者运行在 Strapi 内的特定路由上才能使用传输命令。
¥If you use websockets or Socket.io in your projects, the transfer command will fail. You will need to temporarily disable websockets or Socket.io or ensure that your websocket server is running on a different port than the Strapi server, or a on a specific route within Strapi to use the transfer command.
CLI 命令包含以下参数:
¥The CLI command consists of the following arguments:
选项 | 描述 |
---|---|
--to | 目标 Strapi 实例上 /admin 端点的完整 URL(例如 --to https://my-beautiful-strapi-website/admin ) |
‑‑to‑token | 从 Strapi 目标实例传输令牌。 |
--from | 要从中提取数据的远程 Strapi 实例的 /admin 端点的完整 URL(例如 --from https://my-beautiful-strapi-website/admin ) |
‑‑from‑token | 从 Strapi 源实例传输令牌。 |
--force | 自动回答 "yes" 所有提示,包括潜在的破坏性请求,并以非交互方式运行。 |
--exclude | 使用逗号分隔的数据类型排除数据。可用的类型有:content 、files 和 config 。 |
--only | 仅包含这些数据。可用的类型有:content 、files 和 config 。 |
--throttle | 在传输期间在 "chunks" 之间注入人为延迟的时间(以毫秒为单位)。 |
--verbose | 启用详细日志。 |
需要 --to
或 --from
。
¥Either --to
or --from
is required.
-
数据传输由传输令牌授权,即 从管理面板管理