Skip to main content

ListSnapshots()

This operation lists all snapshot names for a specified collection.

go
func (c *Client) ListSnapshots(ctx context.Context, opt ListSnapshotsOption, callOptions ...grpc.CallOption) ([]string, error)

Request Syntax​

Creates the request for ListSnapshots().

go
option := client.NewListSnapshotsOption(collectionName).
WithDbName(dbName string)

result, err := client.ListSnapshots(option)

PARAMETERS:

  • collectionName (string) -

    [REQUIRED]

    The name of the target collection.

BUILDER METHODS:

  • WithDbName(dbName string)

    This sets the database name. If not set, the default database is used.

RETURN TYPE:

[]string, error

RETURNS:

A list of snapshot names. Returns an error if the operation fails.

PARAMETERS:

  • result ([]string) -

    The []string value returned by ListSnapshots().

ERROR HANDLING:

  • error

    The operation fails. Check err != nil for failure details.

Example​

Demonstrates ListSnapshots() usage.

go
import (
"log"
"context"
"fmt"

"github.com/milvus-io/milvus/client/v3/milvusclient"
)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

milvusAddr := "YOUR_CLUSTER_ENDPOINT"

cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: milvusAddr,
})
if err != nil {
log.Fatal(err)
}

defer cli.Close(ctx)

option := milvusclient.NewListSnapshotsOption("my_collection")

snapshots, err := cli.ListSnapshots(ctx, option)
if err != nil {
// handle error
}

fmt.Println(snapshots)
Minimum SDK versionv3.0.x
Was this page helpful?