fix: restore_test.sh uses upload endpoint and tightens source-file glob
file:// snapshot recovery is disabled by default in recent Qdrant
(returns 403 on /collections/.../snapshots/recover with a file:// URL).
Switched to POST /snapshots/upload with multipart form-data which
doesn't need an allowlist.
Also tightened the find -name glob from "${SOURCE_COLLECTION}_*" to
"${SOURCE_COLLECTION}_[0-9]*" so a source named "mem0_v3" does not
accidentally match "mem0_v3_entities_*" files in the same dir.
This commit is contained in:
parent
fd109ef892
commit
e99b382b16
1 changed files with 13 additions and 8 deletions
|
|
@ -26,11 +26,13 @@ TEST_COLLECTION="${TEST_COLLECTION:-mem0_v3_restore_test}"
|
|||
|
||||
log() { printf '[%s] %s\n' "$(date -u +%FT%TZ)" "$*"; }
|
||||
|
||||
# Pick the most recently-modified backup file matching SOURCE_COLLECTION_*.
|
||||
latest="$(find "$BACKUP_DIR" -type f -name "${SOURCE_COLLECTION}_*" -printf '%T@ %p\n' 2>/dev/null \
|
||||
# Pick the most recent backup for SOURCE_COLLECTION. The "_[0-9]*" suffix
|
||||
# anchors on the timestamp digit so a collection named "mem0_v3" does NOT
|
||||
# also match "mem0_v3_entities_*" files in the same directory.
|
||||
latest="$(find "$BACKUP_DIR" -type f -name "${SOURCE_COLLECTION}_[0-9]*" -printf '%T@ %p\n' 2>/dev/null \
|
||||
| sort -nr | head -1 | cut -d' ' -f2-)"
|
||||
if [ -z "$latest" ]; then
|
||||
log "ERROR: no backup found under $BACKUP_DIR matching ${SOURCE_COLLECTION}_*"
|
||||
log "ERROR: no backup found under $BACKUP_DIR matching ${SOURCE_COLLECTION}_[0-9]*"
|
||||
exit 1
|
||||
fi
|
||||
log "latest backup: $latest"
|
||||
|
|
@ -50,11 +52,14 @@ snap_basename="$(basename "$latest")"
|
|||
log "copying snapshot into container: /tmp/$snap_basename"
|
||||
docker cp "$latest" "$QDRANT_CONTAINER:/tmp/$snap_basename"
|
||||
|
||||
log "restoring into $TEST_COLLECTION"
|
||||
docker exec "$QDRANT_CONTAINER" curl -fsS -X PUT \
|
||||
"http://localhost:6333/collections/$TEST_COLLECTION/snapshots/recover" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"location\":\"file:///tmp/$snap_basename\",\"priority\":\"snapshot\"}" \
|
||||
# Use the upload endpoint (multipart) rather than recover-from-URL —
|
||||
# file:// recovery is disabled by default in recent Qdrant (returns 403),
|
||||
# and upload doesn't need an allowlist.
|
||||
log "restoring into $TEST_COLLECTION via /snapshots/upload"
|
||||
docker exec "$QDRANT_CONTAINER" curl -fsS -X POST \
|
||||
"http://localhost:6333/collections/$TEST_COLLECTION/snapshots/upload?priority=snapshot" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-F "snapshot=@/tmp/$snap_basename" \
|
||||
>/dev/null
|
||||
|
||||
restored_count=$(docker exec "$QDRANT_CONTAINER" curl -fsS -X POST \
|
||||
|
|
|
|||
Loading…
Reference in a new issue