Skip to main content

Backup & Restore

vectlite provides several ways to create backups and restore databases.

Snapshots

Create a self-contained copy of the database at any point:

Python

db.snapshot("/backups/knowledge_2024.vdb")

Node.js

db.snapshot('/backups/knowledge_2024.vdb')

The snapshot file includes all committed data. It does not include uncommitted WAL entries — call compact() first if you need a fully up-to-date snapshot.

Full Backup

A full backup copies the database file and all ANN sidecar files:

Python

db.backup("/backups/full/")

Node.js

db.backup('/backups/full/')

Restore

Restore a backup to a new database path:

Python

restored = vectlite.restore("/backups/full/", "restored.vdb")

Node.js

const restored = vectlite.restore('/backups/full/', 'restored.vdb')

Read-Only Mode

Open a database in read-only mode for safe concurrent access:

Python

ro = vectlite.open("knowledge.vdb", read_only=True)
results = ro.search(query, k=5) # Reads work
ro.upsert(...) # Raises VectLiteError

Node.js

const ro = vectlite.open('knowledge.vdb', { readOnly: true })
const results = ro.search(query, { k: 5 }) // Reads work
ro.upsert(...) // Throws VectLiteError

Read-only mode uses shared file locks, allowing multiple readers to access the same database file simultaneously.