restoreSnapshot()
此操作会将一个 Collection 从快照恢复到新的或现有的 Collection。
await milvusClient.restoreSnapshot(data: RestoreSnapshotReq)
请求语法
await milvusClient.restoreSnapshot({
snapshot_name: string,
source_collection_name: string,
target_collection_name: string,
source_db_name?: string,
target_db_name?: string,
timeout?: number,
client_request_id?: string,
})
参数:
-
snapshot_name (string) -
[必需]
要从中恢复的快照名称。 -
source_collection_name (string) -
[必需]
源 Collection 的名称。 -
target_collection_name (string) -
[必需]
要恢复到的目标 Collection 名称。 -
source_db_name (string) -
源 Database 名称。可选。 -
target_db_name (string) -
目标 Database 名称。可选。 -
timeout (number) -
RPC 允许的可选时长,单位为毫秒。如果将其设置为 undefined,客户端将持续等待,直到服务器响应或发生错误。默认值为 undefined。 -
client_request_id (string) -
用于请求跟踪的跟踪 ID。可选。
返回值 Promise<RestoreSnapshotResponse>
此方法返回一个 promise,解析为 RestoreSnapshotResponse 对象。
{
job_id: string,
status: ResStatus
}
参数:
-
job_id (string) -
异步恢复作业的标识符。将此值传递给getRestoreSnapshotState()以轮询完成状态。 -
ResStatus
一个 ResStatus 对象。-
code (number) -
表示操作结果的代码。如果此操作成功,其值保持为 0。
-
error_code (string | number) -
表示已发生错误的错误代码。如果此操作成功,其值保持为 Success。
-
reason (string) -
表示所报告错误原因的说明。如果此操作成功,其值保持为空字符串。
-
示例
import { MilvusClient } from '@zilliz/milvus2-sdk-node';
const client = new MilvusClient({
address: 'YOUR_CLUSTER_ENDPOINT',
token: 'YOUR_CLUSTER_TOKEN',
});
const res = await client.restoreSnapshot({
snapshot_name: 'snapshot_2024_01',
source_collection_name: 'my_collection',
target_collection_name: 'restored_collection',
});