数据导入
¥Data import
4.6.0This feature requires Strapi version 4.6.0 or later.strapi import
命令是 数据管理功能 的一部分,用于从文件导入数据。默认情况下,strapi import
命令从加密和压缩的 tar.gz.enc
文件导入数据,其中包括:
¥The strapi import
command is part of the Data Management feature and used to import data from a file. By default, the strapi import
command imports data from an encrypted and compressed tar.gz.enc
file which includes:
-
项目配置,
¥the project configuration,
-
实体:你的所有内容,
¥entities: all of your content,
-
链接:你的实体之间的关系,
¥links: relations between your entities,
-
资源:文件存储在上传文件夹中,
¥assets: files stored in the uploads folder,
-
模式,
¥schemas,
-
metadata.json
文件。¥the
metadata.json
file.
以下文档详细介绍了自定义数据导入的可用选项。导入命令和所有可用选项均使用 Strapi CLI 运行。
¥The following documentation details the available options to customize your data import. The import command and all of the available options are run using the Strapi CLI.
-
strapi import
在导入备份文件之前删除所有现有数据,包括数据库和上传目录。¥
strapi import
deletes all existing data, including the database and uploads directory, before importing the backup file. -
源架构和目标架构必须匹配才能成功使用
strapi import
,这意味着所有内容类型必须相同。¥The source and target schemas must match to successfully use
strapi import
, meaning all content types must be identical. -
恢复的数据不包括
Admin users
表,这意味着恢复的实例中createdBy
和updatedBy
为空。¥Restored data does not include the
Admin users
table, which means thatcreatedBy
andupdatedBy
are empty in a restored instance.
指定导入文件
¥Specify the import file
要将数据导入 Strapi 实例,请在目标项目根目录中使用 strapi import
命令。使用 -f
或 --file
选项指定要导入的文件。文件名、扩展名和路径是必需的。如果文件已加密,系统会在导入开始之前提示你输入加密密钥。
¥To import data into a Strapi instance use the strapi import
command in the destination project root directory. Specify the file to be imported using the -f
or --file
option. The filename, extension, and path are required. If the file is encrypted, you are prompted for the encryption key before the import starts.