create_snapshot()
内测版此操作会创建 Collection 的时间点快照。使用快照可备份 Collection 数据和元数据,以便进行灾难恢复或迁移。
请求语法
python
create_snapshot(
collection_name: str,
snapshot_name: str,
description: str = "",
timeout: Optional[float] = None,
**kwargs
) -> None
参数:
-
collection_name (str) -
[REQUIRED]
要创建快照的 Collection 名称。 -
snapshot_name (str) -
[REQUIRED]
快照的唯一名称。不得与现有快照名称冲突。 -
description (str) -
快照的可选人类可读描述。 -
timeout (Optional[float]) -
RPC 的可选超时时长,单位为秒。如果未提供,则使用客户端默认超时时间。
返回类型:
None
异常:
-
MilvusException
如果 Collection 不存在、快照名称已被占用,或操作因任何其他原因失败,则会抛出此异常。
示例
python
from pymilvus import MilvusClient
client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")
# Recommended: flush before creating snapshot to persist in-memory data
client.flush(collection_name="my_collection")
client.create_snapshot(
collection_name="my_collection",
snapshot_name="backup_20260418",
description="Daily backup before schema change",
)