You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: auto-fetch-collections-from-s3
* update documentation
* Update ConfigMap with latest script changes
* fix: harden qdrant restore script and align restore .env example (#110)
Follow-up to feat/auto-fetch-collections-from-s3 with three small fixes
surfaced during review.
- track_collection: skip the read loop when the jq result is empty. Bash
here-strings always append a newline, so `done <<< ""` would otherwise
iterate once with an empty item and write a bogus `host,` line to
$QDRANT_COLLECTIONS_FILE. Affects `get_coll` against an empty source.
- generate_snapshot_file_from_s3: fix word order in the non-error exit
message so the filename lands in the correct position.
- UPGRADE-OPERATIONS.md restore example: set QDRANT_SOURCE_HOSTS="" to
match the new restore-from-S3-only contract used by the k8s manifests;
move the port-forward note to QDRANT_RESTORE_HOSTS where it belongs.
- Sync configmap-script.yaml via config_map_updater.sh.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tobias Pfaffelmoser <tobias.pfaffelmoser@ext.aleph-alpha.com>
Update the following environment varibles accordingly;
164
164
165
165
1. Update the `secretKeyRef.name` on all `env:` entries under `env.[*].valueFrom` to the name of the kubernetes secrets deployed when configuring Qdrant.
166
-
2. Update the `QDRANT_SOURCE_HOSTS` to the kubernetes service domain of the source Qdrant deployment.
166
+
2. Update the `QDRANT_SOURCE_HOSTS` to empty `""`.
167
167
3. Update the `QDRANT_RESTORE_HOSTS` to the target qdrant cluster service domain.
168
-
4. `GET_PEERS_FROM_CLUSTER_INFO` should be `true` to discover qdrant cluster peers when backing up collections.
168
+
4. `GET_PEERS_FROM_CLUSTER_INFO` should be `false` during restore.
169
169
5. `CURL_TIMEOUT` is set at `3000` seconds. This is the max time curl will waitforrequest to complete. Its increasedin scenarios where restoration takes a while.
170
170
6. `QDRANT_S3_LINK_EXPIRY_DURATION` is set at `3600`. This is the duration that an s3 presigned url will be active. The url is used during the recovery process.
171
171
7. `QDRANT_WAIT_ON_TASK` is set as `true`. This configuation make restoration process synchronous meaning 'wait for snapshot process to finish successfully before moving on'. Its used during backup and recovery.
# Guard against the bash `<<<` quirk: a here-string of an empty value still
116
+
# produces a single newline, so the loop below would iterate once with an
117
+
# empty item and write a bogus `host,` line to $QDRANT_COLLECTIONS_FILE.
118
+
if [[ -z "$_result" ]]; then
119
+
return
120
+
fi
121
+
111
122
while read -r item; do
112
123
local collection_name=""
113
124
collection_name=$(jq -r '.name' <<< "$item")
@@ -141,7 +152,11 @@ data:
141
152
142
153
# creates and appends created collection snapshot from a qdrant node to $QDRANT_SNAPSHOTS_FILE
143
154
track_created_collection_snapshot() {
144
-
local host="${source_hosts[0]}"
155
+
local host="${source_hosts[0]:-}"
156
+
if [[ -z "$host" ]]; then
157
+
_printf "source host is not available for fetching collection snapshots. Please ensure QDRANT_SOURCE_HOSTS is set correctly in your environment variables.\n"
158
+
exit 1
159
+
fi
145
160
local collection_name="$1"
146
161
local result=""
147
162
local status=""
@@ -342,11 +357,61 @@ data:
342
357
fi
343
358
}
344
359
360
+
# discovers collection names from the S3 snapshots prefix and stores them in $QDRANT_COLLECTIONS_FILE
361
+
fetch_collections_from_s3() {
362
+
local prefix="snapshots"
363
+
local result=""
364
+
365
+
_printf "fetching collections from s3 bucket %s under %s/\n" "$QDRANT_S3_BUCKET_NAME" "$prefix"
366
+
367
+
result=$(mc ls --json "$QDRANT_S3_ALIAS/$QDRANT_S3_BUCKET_NAME/$prefix/")
368
+
369
+
if [ "$result" = "" ]; then
370
+
_printf "no collections found in s3 path: %s/%s/ ...skipping!\n" "$QDRANT_S3_BUCKET_NAME" "$prefix"
371
+
return
372
+
fi
373
+
374
+
collections_count=0
375
+
_result=$(jq -c '.' <<< "$result")
376
+
377
+
while read -r item; do
378
+
local status=""
379
+
local object_key=""
380
+
local collection_name=""
381
+
382
+
status=$(jq -r '.status?' <<< "$item")
383
+
if [ "$status" != "success" ]; then
384
+
_printf "failed to list collections from s3, got this instead %s\n" "${item//[[:space:]]/}"
385
+
continue
386
+
fi
387
+
388
+
object_key=$(jq -r '.key' <<< "$item") # e.g. "my_collection/" from mc ls on snapshots/
_printf "%s file updated, found %d collection(s) from s3!\n" "$QDRANT_COLLECTIONS_FILE" "$collections_count"
401
+
collections_count=0
402
+
}
403
+
345
404
# generates a list of collection snapshots from a s3 and appends it to $QDRANT_SNAPSHOTS_FILE
346
405
generate_snapshot_file_from_s3() {
347
406
local datetime="${1:-}"
407
+
348
408
if [[ ! -s "$QDRANT_COLLECTIONS_FILE" ]]; then
349
-
get_collections
409
+
fetch_collections_from_s3
410
+
fi
411
+
412
+
if [ ! -f "$QDRANT_COLLECTIONS_FILE" ]; then
413
+
_printf "non error exit since file %s does not exist.\n" "$QDRANT_COLLECTIONS_FILE"
414
+
exit 0
350
415
fi
351
416
352
417
snapshot_count=0
@@ -496,7 +561,11 @@ data:
496
561
497
562
# gets the collection aliases from a qdrant node and appends it to $QDRANT_COLLECTION_ALIASES file
498
563
get_collection_aliases() {
499
-
local host="${source_hosts[0]}"
564
+
local host="${source_hosts[0]:-}"
565
+
if [[ -z "$host" ]]; then
566
+
_printf "source host is not available for fetching collection aliases. Please ensure QDRANT_SOURCE_HOSTS is set correctly in your environment variables.\n"
567
+
exit 1
568
+
fi
500
569
local result=""
501
570
local status=""
502
571
@@ -597,7 +666,11 @@ data:
597
666
# restores collection aliases to a qdrant node and appends progress to $QDRANT_ALIAS_RECOVERY_HISTORY_FILE
598
667
recover_collection_aliases() {
599
668
600
-
local host="${restore_hosts[0]}"
669
+
local host="${restore_hosts[0]:-}"
670
+
if [[ -z "$host" ]]; then
671
+
_printf "restore host is not available for recovering collection aliases. Please ensure QDRANT_RESTORE_HOSTS is set correctly in your environment variables.\n"
672
+
exit 1
673
+
fi
601
674
602
675
603
676
if [ "$BACKUP_COLLECTION_ALIASES_ON_S3" = "true" ]; then
@@ -667,7 +740,12 @@ data:
667
740
668
741
# gets qdrant peer host url using cluster info endpoint. Sets the port to $QDRANT_HTTP_PORT the http port.
669
742
get_peers_from_cluster_info() {
670
-
local host="${source_hosts[0]}"
743
+
local host="${source_hosts[0]:-}"
744
+
if [[ -z "$host" ]]; then
745
+
_printf "source host is not available. Please ensure QDRANT_SOURCE_HOSTS is set correctly in your environment variables. If restoring snapshots set QDRANT_SOURCE_HOSTS and GET_PEERS_FROM_CLUSTER_INFO to empty string.\n"
746
+
exit 1
747
+
fi
748
+
671
749
result=$(_curl GET "$host/cluster" --header "api-key: $QDRANT_API_KEY")
Copy file name to clipboardExpand all lines: qdrant-backup-restore/k8s/configmap-snapshot.yaml
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,12 @@ metadata:
6
6
app: qdrant-snapshots-file
7
7
component: script
8
8
data:
9
+
# this is used to provide a list of snapshots to restore (comma separated list of collection names and snapshot names, host is optional (first column is host))
Copy file name to clipboardExpand all lines: qdrant-backup-restore/k8s/restore-job.yaml
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -47,19 +47,21 @@ spec:
47
47
name: qdrant-credentials-minio
48
48
key: QDRANT_API_KEY
49
49
- name: QDRANT_SOURCE_HOSTS
50
-
value: "http://qdrant-headless:6333"#change this to your source qdrant kubernetes headless service name
50
+
value: ""#leave empty if source host is not available
51
51
- name: QDRANT_S3_ENDPOINT_URL
52
52
value: "http://minio.default.svc.cluster.local:9000"# change this to your s3 endpoint url
53
53
- name: QDRANT_RESTORE_HOSTS
54
-
value: "http://qdrantr2-headless:6333"# change this to your target qdrant kubernetes headless service name
54
+
value: "http://qdrant-headless:6333"# change this to your target qdrant kubernetes headless service name
55
55
- name: GET_PEERS_FROM_CLUSTER_INFO
56
-
value: "true"
56
+
value: "false"
57
57
- name: QDRANT_SNAPSHOT_DATETIME_FILTER
58
-
value: ""#change tis to filter snapshts based on date (glob matching is used)
58
+
value: ""#set this to filter snapshots based on date (glob matching is used) e.g "2026-01-29" = all snapshots in 29th January 2026, "2026-01" = all snapshots in January 2026.
59
59
- name: CURL_TIMEOUT
60
60
value: "3000"# increase if more time is needed for a single restore
61
61
- name: MC_CONFIG_DIR
62
62
value: "mc"# sets the configuration location for mc S3 client
0 commit comments