Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI Commands

Complete reference for the aeordb command-line interface.

aeordb start

Start the AeorDB server.

aeordb start [OPTIONS]

Flags

FlagShortDefaultDescription
--config-cPath to a TOML configuration file
--port-p6830TCP port to listen on
--host0.0.0.0Bind address
--database-Ddata.aeordbPath to the .aeordb database file
--log-formatprettyLog output format: pretty or json
--auth(none)Auth provider URI (see below)
--hot-dir(database parent dir)Directory for write-ahead hot files
--cors-origins(disabled)CORS allowed origins
--tls-certPath to TLS certificate PEM file (requires --tls-key)
--tls-keyPath to TLS private key PEM file (requires --tls-cert)
--jwt-expiry3600JWT token lifetime in seconds
--chunk-size262144Write chunk size in bytes (256 KiB)
--peersComma-separated peer URLs to register at startup (persisted, idempotent)
--joinURL of an existing cluster member to join (one-shot; fetches the cluster’s signing key)
--join-tokenRoot API key (or bearer token) of the existing cluster member, required with --join

Auth Modes

The --auth flag accepts several formats:

ValueModeDescription
(not set)DisabledNo authentication required (dev mode)
false, null, no, 0DisabledExplicitly disable authentication
selfSelf-containedAeorDB manages API keys internally
file:///path/to/identityFile-basedLoad identity from a file

When using self mode, the root API key is printed once on first startup. Save it – it cannot be retrieved again (but can be reset with emergency-reset).

CORS

ValueBehavior
(not set)CORS disabled
*Allow all origins
https://a.com,https://b.comAllow specific comma-separated origins

Examples

# Development mode (no auth, default port)
aeordb start

# Production with auth on port 8080
aeordb start --port 8080 --database /var/lib/aeordb/prod.aeordb --auth self --log-format json

# Custom hot directory and CORS
aeordb start --database data.aeordb --hot-dir /fast-ssd/hot --cors-origins "*"

# HTTPS with TLS
aeordb start --tls-cert /etc/ssl/cert.pem --tls-key /etc/ssl/key.pem --port 443

# Using a config file
aeordb start --config aeordb.toml

# Config file with CLI overrides
aeordb start --config aeordb.toml --port 8080 --auth false

# Join an existing cluster (one-shot — adopts the cluster's JWT signing key)
aeordb start --database nodeB.aeordb --auth self \
  --join http://nodeA:6830 --join-token "$NODE_A_ROOT_KEY"

# Register additional peers on a node already in a cluster
aeordb start --database data.aeordb --peers "http://nodeC:6830,http://nodeD:6830"

# Show version
aeordb --version

What Happens on Start

  1. Binds HTTP and serves /system/health with status: "starting"
  2. Scans the configured emergency-spill locations for unresolved artifacts tied to this database and refuses startup if any are found
  3. Opens (or creates) the database file
  4. Rebuilds startup state from the WAL if the previous shutdown was dirty
  5. Bootstraps root API key (if --auth self and no key exists yet)
  6. Resets any tasks left in Running state from a previous crash to Pending
  7. Starts background workers:
    • Heartbeat: emits clock-sync pulses every 15 seconds
    • Metrics: emits system metrics snapshots every 15 seconds
    • Cron scheduler: checks /.config/cron.json every 60 seconds
    • Task worker: dequeues and executes background tasks
    • Webhook dispatcher: delivers events to registered webhook URLs
  8. Switches the full API router to ready and emits server_ready on eligible SSE streams
  9. On CTRL+C or SIGTERM, stops accepting new storage work, waits for active work to drain, then flushes buffers

The shutdown drain window defaults to 600 seconds. Set AEORDB_SHUTDOWN_OPERATION_WAIT_SECS to override it.


aeordb verify

Verify database integrity and optionally repair recoverable issues.

aeordb verify [OPTIONS]

Flags

FlagShortDefaultDescription
--database-Ddata.aeordbPath to the .aeordb database file
--repairfalseRepair recoverable issues
--force-fix-in-placefalseApply repairs directly to the original database instead of creating <database>.repaired
--yesfalseAccept emergency-spill replay prompts without interactive confirmation

Examples

# Verify without modifying the database
aeordb verify --database data.aeordb

# Repair into a copy
aeordb verify --repair --database data.aeordb

# Repair the original database in place
aeordb verify --repair --force-fix-in-place --database data.aeordb

# Unattended emergency-spill repair after reviewing the artifacts
aeordb verify --repair --force-fix-in-place --yes --database data.aeordb

Directory Tree Repair

aeordb verify reports damaged B-tree directory branches under the Directory Consistency section. Normal read paths can return the readable portion of a damaged B-tree directory, but verification surfaces the missing or corrupt branch so it is not silently hidden.

When --repair is used, B-tree directory issues are repaired by first rebuilding only the affected B-tree directory from current live path records. If targeted repair cannot recover the issue, repair falls back to rebuilding the live directory tree from path-key FileRecords.

Emergency Spill Recovery

If startup finds unresolved emergency-spill artifacts for the target database, it exits before serving the normal API and prints the repair command:

aeordb verify --repair --force-fix-in-place -D /path/to/database.aeordb

Repair scans all emergency-spill locations, orders matching artifacts oldest-first, prints the hot-tail and WAL-tail files it found, and prompts before replay. --yes skips the prompt for automation. Spill replay must run in place because the artifact marker belongs to the original database path.

WAL-tail bytes are the only spill payload replayed into the database file. hot-tail.bin and index-buffer.json are preserved and reported, but repair does not trust them as primary data: after WAL-tail replay it forces a WAL rebuild, reconstructs reusable gaps, and publishes a fresh hot tail.


aeordb gc

Run garbage collection to reclaim space from unreachable entries.

aeordb gc [OPTIONS]

Flags

FlagShortDefaultDescription
--database-Ddata.aeordbPath to the .aeordb database file
--dry-runfalseReport what would be collected without actually deleting

Examples

# Run GC
aeordb gc --database data.aeordb

# Preview what would be collected
aeordb gc --database data.aeordb --dry-run

Output

AeorDB Garbage Collection
Database: data.aeordb

Versions scanned: 3
Live entries:     1247
Garbage entries:  89
Reclaimed:        1.2 MB
Duration:         0.3s

See Garbage Collection for details on the mark-and-sweep algorithm.


aeordb export

Export a version as a self-contained .aeordb file.

aeordb export [OPTIONS]

Flags

FlagShortDefaultDescription
--database-Ddata.aeordbSource database file
--output-o(required)Output .aeordb file path
--snapshot-s(none)Named snapshot to export
--hash(none)Specific version hash to export (hex-encoded)

If neither --snapshot nor --hash is provided, HEAD is exported.

Examples

# Export HEAD
aeordb export --database data.aeordb --output backup.aeordb

# Export a named snapshot
aeordb export --database data.aeordb --output backup-v1.aeordb --snapshot v1

# Export a specific hash
aeordb export --database data.aeordb --output backup.aeordb --hash abc123def456...

The output file must not already exist.

See Backup & Restore for full backup workflows.


aeordb diff

Create a patch .aeordb containing only the changeset between two versions.

aeordb diff [OPTIONS]

Flags

FlagShortDefaultDescription
--database-Ddata.aeordbSource database file
--output-o(required)Output patch file path
--from(required)Base version (snapshot name or hex hash)
--toHEADTarget version (snapshot name or hex hash)

Examples

# Diff between two snapshots
aeordb diff --database data.aeordb --output patch.aeordb --from v1 --to v2

# Diff from a snapshot to HEAD
aeordb diff --database data.aeordb --output patch.aeordb --from v1

# Diff between raw hashes
aeordb diff --database data.aeordb --output patch.aeordb --from abc123... --to def456...

The --from and --to arguments first try snapshot name lookup, then fall back to interpreting the value as a hex-encoded hash.

See Backup & Restore for incremental backup workflows.


aeordb import

Import an export or patch .aeordb file into a target database.

aeordb import [OPTIONS]

Flags

FlagShortDefaultDescription
--database-Ddata.aeordbTarget database file
--file-f(required)Backup or patch file to import
--forcefalseSkip base version verification for patches
--promotefalseAutomatically set HEAD to the imported version

Examples

# Import a full backup
aeordb import --database data.aeordb --file backup.aeordb

# Import and promote HEAD
aeordb import --database data.aeordb --file backup.aeordb --promote

# Force-import a patch even if base doesn't match
aeordb import --database data.aeordb --file patch.aeordb --force --promote

Patch Base Verification

When importing a patch (backup_type=2), AeorDB verifies that the target database’s HEAD matches the patch’s base version. Use --force to bypass this check.

See Backup & Restore for restore workflows.


aeordb promote

Promote a version hash to HEAD.

aeordb promote [OPTIONS]

Flags

FlagShortDefaultDescription
--database-Ddata.aeordbDatabase file
--hash(required)Hex-encoded version hash to promote

Examples

aeordb promote --database data.aeordb --hash abc123def456...

The command verifies the hash exists in the database before promoting.


aeordb stress

Run stress tests against a running AeorDB instance.

aeordb stress [OPTIONS]

Flags

FlagShortDefaultDescription
--target-thttp://localhost:6830Target server URL
--api-key-a(required)API key for authentication
--concurrency-c10Number of concurrent workers
--duration-d10sTest duration (e.g., 30s, 5m)
--operation-omixedOperation type: write, read, or mixed
--file-size-s1kbFile size for writes (e.g., 512b, 1kb, 1mb)
--path-prefix-p/stress-testPath prefix for stress test files

Examples

# Quick mixed read/write test
aeordb stress --api-key $API_KEY

# Heavy write test for 5 minutes
aeordb stress --api-key $API_KEY --operation write --concurrency 50 --duration 5m --file-size 10kb

# Read-only test against production
aeordb stress --target https://prod.example.com --api-key $API_KEY --operation read --concurrency 100 --duration 30s

aeordb emergency-reset

Revoke the current root API key and generate a new one. Use this if the root key is lost or compromised.

aeordb emergency-reset [OPTIONS]

Flags

FlagShortDefaultDescription
--database-D(required)Database file
--forcefalseSkip confirmation prompt

Examples

# Interactive (prompts for confirmation)
aeordb emergency-reset --database data.aeordb

# Non-interactive
aeordb emergency-reset --database data.aeordb --force

What Happens

  1. Finds all API keys linked to the root user (nil UUID)
  2. Revokes each one
  3. Generates a new root API key
  4. Prints the new key (shown once, save it immediately)
WARNING: This will invalidate the current root API key.
A new root API key will be generated.
Proceed? [y/N]: y
Revoked 1 existing root API key(s).

==========================================================
  NEW ROOT API KEY (shown once, save it now!):
  aeordb_abc123def456...
==========================================================

This command requires direct file access to the database – it cannot be run over HTTP. It is intended for recovery scenarios where you have lost the root API key.


See Also