Skip to content

Snapshots

Create, list, and delete snapshots for a Qdrant collection.

This example assumes using Qdrant; is in scope and apiKey contains your Qdrant API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var client = Client;
var collectionName = $"test_snapshots_{Guid.NewGuid():N}";

// Create a collection to snapshot.

await client.Collections.CreateCollectionAsync(
    collectionName: collectionName,
    vectors: new VectorParams
    {
        Size = 4,
        Distance = Distance.Cosine,
    });

// Create a snapshot of the collection.

var createResponse = await client.Snapshots.CreateSnapshotAsync(
    collectionName: collectionName,
    wait: true);

var snapshotName = createResponse.Result.Name;
Console.WriteLine($"Created snapshot: {snapshotName}");

// List all snapshots for the collection.

var listResponse = await client.Snapshots.ListSnapshotsAsync(
    collectionName: collectionName);

Console.WriteLine($"Found {listResponse.Result!.Count} snapshot(s).");

// Delete the snapshot.

var deleteResponse = await client.Snapshots.DeleteSnapshotAsync(
    collectionName: collectionName,
    snapshotName: snapshotName,
    wait: true);

Console.WriteLine($"Deleted snapshot: {snapshotName}");

// Verify the snapshot was deleted.

var listAfterDelete = await client.Snapshots.ListSnapshotsAsync(
    collectionName: collectionName);

// Cleanup: delete the collection.

await client.Collections.DeleteCollectionAsync(
    collectionName: collectionName);