Skip to main content

DropSnapshot()

This operation permanently deletes a snapshot. Once dropped, the snapshot data cannot be recovered.

go
func (c *Client) DropSnapshot(ctx context.Context, opt DropSnapshotOption, callOptions ...grpc.CallOption) error

Request Syntax​

Creates the request for DropSnapshot().

go
option := client.NewDropSnapshotOption(snapshotName, collectionName).
WithDbName(dbName string)

err := client.DropSnapshot(option)

PARAMETERS:

  • name (string) -

    [REQUIRED]

    The name of the snapshot to drop.

  • collectionName (string) -

    [REQUIRED]

    The name of the collection the snapshot belongs to.

BUILDER METHODS:

  • WithDbName(dbName string)

    This sets the name of the database to which the specified collection belongs.

RETURN TYPE:

error

RETURNS:

Returns nil on success. Returns an error if the snapshot does not exist or the operation fails.

ERROR HANDLING:

  • error

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

Example​

Demonstrates DropSnapshot() 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.NewDropSnapshotOption("backup_20260401", "my_collection")

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

fmt.Println("Snapshot dropped successfully")
Minimum SDK versionv3.0.x
Was this page helpful?