CreateSnapshot()

This operation creates a snapshot for a collection. Use it before destructive maintenance or restore testing.

Status CreateSnapshot(const CreateSnapshotRequest& request)

Request Syntax

auto request = milvus::CreateSnapshotRequest()
    .WithDatabaseName("default")
    .WithCollectionName("book")
    .WithDescription("before quarterly reindex")
    .WithCompactionProtectionSeconds(3600);

REQUEST METHODS:

  • WithDatabaseName(const std::string& db_name)

    Sets the database that contains the collection.

  • WithCollectionName(const std::string& collection_name)

    Sets the collection to snapshot.

  • WithDescription(const std::string& description)

    Sets an optional snapshot description.

  • WithCompactionProtectionSeconds(int64_t seconds)

    Sets how long compaction should preserve data needed by the snapshot.

RETURNS:

Status

EXCEPTIONS:

  • std::exception

    This exception can be raised if the request cannot be sent or the response cannot be parsed.

Example

auto client = milvus::MilvusClientV2::Create();
milvus::ConnectParam connect_param{"http://localhost:19530", "root:Milvus"};
auto status = client->Connect(connect_param);
if (!status.IsOk()) {
    std::cout << status.Message() << std::endl;
}

auto request = milvus::CreateSnapshotRequest()
    .WithDatabaseName("default")
    .WithCollectionName("book")
    .WithDescription("before quarterly reindex")
    .WithCompactionProtectionSeconds(3600);
status = client->CreateSnapshot(request);
if (!status.IsOk()) {
    std::cout << status.Message() << std::endl;
}

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?