Skip to content

Back up a collection with Qdrant snapshots

View as Markdown

Qdrant can take a snapshot of one collection on one node. These snapshots are stored on that node’s disk, separate from the snapshots in the Snapshot tab. Use them when you need to download a collection.

You need a Running database, its Endpoint URL, and its API Key; see Connect to a vector database. Each call goes to one node and one collection, so repeat it for every node. Nodes are numbered from 0 to the node count minus 1. Add node-<node> to the address, where <node> is the node’s number. <your-endpoint-url> is the Endpoint URL, <your-api-key> is your API key, and <collection_name> is the collection.

from qdrant_client import QdrantClient
client = QdrantClient(
host="<your-endpoint-url>", port=6333,
prefix="node-<node>", api_key="<your-api-key>"
)
client.create_snapshot(collection_name="<collection_name>")

With cURL:

curl -X POST \
-H "api-key: <your-api-key>" \
https://<your-endpoint-url>:6333/node-<node>/collections/<collection_name>/snapshots
client.list_snapshots(collection_name="<collection_name>")
curl -X GET \
-H "api-key: <your-api-key>" \
https://<your-endpoint-url>:6333/node-<node>/collections/<collection_name>/snapshots

<snapshot_name> is a name from the list.

curl -X GET \
-H "api-key: <your-api-key>" \
https://<your-endpoint-url>:6333/node-<node>/collections/<collection_name>/snapshots/<snapshot_name>

<file_location> is where the snapshot file is.

client.recover_snapshot(
"<collection_name>",
"<file_location>"
)
curl -X PUT \
-H "api-key: <your-api-key>" \
-d '{ "location": "<file_location>" }' \
https://<your-endpoint-url>:6333/node-<node>/collections/<collection_name>/snapshots/recover

To restore from a file on your computer, upload it. <file_name> is the snapshot file.

curl -X POST \
'https://<your-endpoint-url>:6333/node-<node>/collections/<collection_name>/snapshots/upload?priority=snapshot' \
-H 'api-key: <your-api-key>' \
-H 'Content-Type: multipart/form-data' \
-F 'snapshot=@/path/to/<file_name>.snapshot'

A restore takes a priority that decides which data wins when both exist. Pass one of these as the priority value of the upload address:

replica (default) Keeps existing data over snapshot data.
snapshot Keeps snapshot data over existing data.
no_sync Restores without any extra synchronization.
client.delete_snapshot(
collection_name="<collection_name>",
snapshot_name="<snapshot_name>"
)
curl -X DELETE \
-H "api-key: <your-api-key>" \
https://<your-endpoint-url>:6333/node-<node>/collections/<collection_name>/snapshots/<snapshot_name>

For a backup of the whole database in one step, take a snapshot in the portal. For help, see Troubleshooting Vector Database.