Skip to content

About

A DuckDB extension for reading Milvus backups with SQL

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

milvus-backup-duckdb-reader

Inspect Milvus backups directly with SQL — local disk or S3, zero restore.

Latest Release DuckDB v2.0.1 License

Quick Start  ·  Walkthrough  ·  S3  ·  SQL Functions  ·  Reference  ·  Development

A DuckDB extension for reading Milvus backups directly with SQL. Point it at a backup directory — on local disk or s3:// — and inspect inventories, collection schemas, and row data before (or instead of) restoring into a live cluster.

Supports both milvus-backup binlog backups and Milvus 3.0 snapshot backups.

DuckDB terminal session querying Milvus backups and vector rows with SQL

Why

Inspecting a backup normally requires restoring it into a matching Milvus instance first — just to answer read-only questions. This extension queries the backup files directly:

  • Inventory & verify backups — Check backup sizes, ages, schemas, indexes, and row counts before restoring anywhere that matters.
  • Query & export data with SQL — Spot-check rows, slice vectors, join against other tables, diff two backups, or export straight to Parquet/CSV.
  • Inspect deleted rows — Apply deletes by default to match a restored cluster, or disable filtering to audit deleted/upserted rows with __row_id and __timestamp.
  • Works on local disk and s3:// — Reads through DuckDB's filesystem (httpfs), reading only the columns your query references.

Quick Start

Important

Requires DuckDB v2.0.1 exactly (download CLI), and the downloaded file must be renamed to milvus_backup.duckdb_extension before loading.

1. Download the prebuilt extension

Grab the binary for your platform from the v0.1.1 release:

Platform Asset
macOS (Apple silicon) milvus_backup-0.1.1-duckdb2.0.1-osx_arm64.duckdb_extension
Linux (x86_64) milvus_backup-0.1.1-duckdb2.0.1-linux_amd64.duckdb_extension
Linux (arm64) milvus_backup-0.1.1-duckdb2.0.1-linux_arm64.duckdb_extension

Rename the asset (and on macOS, clear the browser quarantine attribute once):

mv milvus_backup-0.1.1-duckdb2.0.1-osx_arm64.duckdb_extension milvus_backup.duckdb_extension
xattr -d com.apple.quarantine milvus_backup.duckdb_extension   # macOS, browser downloads only

2. Load in DuckDB

Start DuckDB with -unsigned and load the extension by absolute path:

duckdb -unsigned
LOAD '/abs/path/to/milvus_backup.duckdb_extension';

SELECT milvus_backup_version();
┌─────────────────────────┐
│ milvus_backup_version() │
│         varchar         │
├─────────────────────────┤
│ milvus_backup 0.1.1     │
└─────────────────────────┘

Need another platform (e.g. macOS Intel), WASM, or another DuckDB version? See the Development Guide.

Walkthrough

Suppose /mnt/backups contains two backups: backup_20261027 (binlog format) and backup_20261101 (snapshot format). The exact same queries work against an s3:// root.

1. List backups

One row per backup, reading metadata only:

SELECT name, milvus_version, format, databases, collection_names,
       num_rows_inserted, has_delete_logs, has_rbac
FROM milvus_backups('/mnt/backups');
┌─────────────────┬────────────────┬──────────┬────────────┬───────────────────────────┬───────────────────┬─────────────────┬──────────┐
│      name       │ milvus_version │  format  │ databases  │     collection_names      │ num_rows_inserted │ has_delete_logs │ has_rbac │
│     varchar     │    varchar     │ varchar  │ varchar[]  │         varchar[]         │       int64       │     boolean     │ boolean  │
├─────────────────┼────────────────┼──────────┼────────────┼───────────────────────────┼───────────────────┼─────────────────┼──────────┤
│ backup_20261027 │ v3.0.0         │ binlog   │ [db1, db2] │ [db1.messages, db1.users] │                 7 │ true            │ true     │
│ backup_20261101 │ v3.0.0         │ snapshot │ [db9]      │ [db9.docs]                │              NULL │ NULL            │ NULL     │
└─────────────────┴────────────────┴──────────┴────────────┴───────────────────────────┴───────────────────┴─────────────────┴──────────┘

Fields the metadata does not record return NULL rather than a fabricated zero.

2. Inspect collections & schemas

One row per collection, with fields and indexes as nested structs (you can also pass a single backup path directly, e.g. milvus_backup_collections('/mnt/backups/backup_20261027')):

SELECT collection_name, db_name, num_rows_inserted,
       has_delete_logs, has_index,
       fields[1].name AS pk_field, fields[2].name AS vec_field, fields[2].dim AS vector_dim
FROM milvus_backup_collections('/mnt/backups', 'backup_20261027');
┌─────────────────┬─────────┬───────────────────┬─────────────────┬───────────┬──────────┬───────────┬────────────┐
│ collection_name │ db_name │ num_rows_inserted │ has_delete_logs │ has_index │ pk_field │ vec_field │ vector_dim │
│     varchar     │ varchar │       int64       │     boolean     │  boolean  │ varchar  │  varchar  │   int64    │
├─────────────────┼─────────┼───────────────────┼─────────────────┼───────────┼──────────┼───────────┼────────────┤
│ messages        │ db1     │                 7 │ true            │ true      │ id       │ vec       │          4 │
│ users           │ db1     │              NULL │ NULL            │ NULL      │ id       │ NULL      │       NULL │
└─────────────────┴─────────┴───────────────────┴─────────────────┴───────────┴──────────┴───────────┴────────────┘

3. Query rows and vectors

milvus_backup_scan returns one column per collection field. Vectors arrive as FLOAT[dim] arrays, and deletes are applied by default to match a restored Milvus cluster:

SELECT count(*) FROM milvus_backup_scan('/mnt/backups', 'backup_20261027', 'messages');

SELECT id, vec[1:4], meta
FROM milvus_backup_scan('/mnt/backups', 'backup_20261027', 'messages')
WHERE id < 3;
┌──────────────┐
│ count_star() │
│    int64     │
├──────────────┤
│      5       │
└──────────────┘
┌───────┬──────────────────────┬────────────────┐
│  id   │       vec[1:4]       │      meta      │
│ int64 │       float[4]       │    varchar     │
├───────┼──────────────────────┼────────────────┤
│     0 │ [0.1, 0.2, 0.3, 0.4] │ {"lang": "en"} │
│     2 │ [0.5, 0.6, 0.7, 0.8] │ {"lang": "zh"} │
└───────┴──────────────────────┴────────────────┘

Only referenced columns are read — SELECT count(*) never decodes vector payloads, and LIMIT stops early.

4. Inspect deleted rows

Disable delete filtering or expose system columns (__row_id, __timestamp) to inspect raw inserted rows:

SELECT count(*)
FROM milvus_backup_scan('/mnt/backups', 'backup_20261027', 'messages', apply_deletes = false);

SELECT id, __row_id, __timestamp
FROM milvus_backup_scan('/mnt/backups', 'backup_20261027', 'messages',
                        include_system = true, apply_deletes = false)
WHERE id <= 1;
┌──────────────┐
│ count_star() │
│    int64     │
├──────────────┤
│      7       │
└──────────────┘
┌───────┬──────────┬─────────────┐
│  id   │ __row_id │ __timestamp │
│ int64 │  int64   │    int64    │
├───────┼──────────┼─────────────┤
│     0 │     1000 │          50 │
│     1 │     1001 │          55 │
└───────┴──────────┴─────────────┘

Reading from S3

Install and load httpfs, configure an S3 secret, and pass s3:// URIs to any function:

INSTALL httpfs;
LOAD 'httpfs';

CREATE SECRET (
    TYPE S3,
    KEY_ID 'AKIA...',
    SECRET '...',
    REGION 'us-east-1'
);

SELECT name, format, num_rows_inserted
FROM milvus_backups('s3://my-bucket/milvus-backups');

SELECT count(*)
FROM milvus_backup_scan('s3://my-bucket/milvus-backups', 'backup_20261027', 'messages');

Tip

To reuse ambient AWS credentials (env vars, ~/.aws, or IAM roles), use CREATE SECRET (TYPE S3, PROVIDER CREDENTIAL_CHAIN);.

SQL Functions

All functions are read-only. Metadata functions never read data files.

Function Purpose
milvus_backup_version() Return the loaded extension version
milvus_backups(root_path) List all backups under a root directory
milvus_backup_collections(root_path, backup_name) / (path) List collections, schemas, and indexes in one backup
milvus_backup_scan(root_path, backup_name, collection) / (path, collection) Scan rows of a collection (qualify as db.collection if ambiguous)

milvus_backup_scan accepts two optional named parameters:

  • apply_deletes = true — Apply delete logs to match a restored cluster (false returns raw inserted rows).
  • include_system = false — Prepend __row_id and __timestamp columns (BIGINT).

For full output schemas, Milvus-to-DuckDB type mappings, and Milvus 3.0 snapshot caveats, see the Function Reference.

Roadmap

  • Backup inventory & collection schema inspection (milvus_backups, milvus_backup_collections)
  • Binlog & Milvus 3.0 snapshot scanning (milvus_backup_scan)
  • Local disk & s3:// support via httpfs
  • Delete replay and raw/system-column audit options
  • Multi-collection scans with schema consistency checks
  • milvus_backup_verify() for backup integrity verification

Documentation & Contributing

  • Function Reference — Full column schemas, type mappings, and snapshot-format notes
  • Development Guide — Building from source, running tests, VS Code debugging, WASM, and upgrading DuckDB
  • Architecture — Data-flow diagram, workspace layout, and format invariants

Bug reports and pull requests are welcome! Open an issue or follow the Development Guide and commit guidelines.

License

Licensed under the Apache License 2.0. See LICENSE.

About

A DuckDB extension for reading Milvus backups with SQL

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages