Skip to content

Bulk import/export for bootstrapping #20

@tac0turtle

Description

@tac0turtle

Summary

Support direct DB import/export to bootstrap new apex instances without syncing millions of heights over RPC.

Use case

A new apex deployment for a rollup with 2M+ DA heights of history. RPC sync at ~100 heights/sec = ~5.5 hours. Direct DB import from a snapshot or another indexer = minutes.

Commands

# Export from a running or stopped apex instance
apex export --namespaces eden,xo --from 1000000 --to 2000000 --output dump.sql

# Import into a new instance
apex import --input dump.sql

Requirements

Export

  • Dump headers and blobs tables for specified height range and namespaces
  • Output format: SQL INSERT statements (portable, inspectable)
  • Optional: compressed output (gzip)
  • Can run against a live DB (SQLite WAL mode supports concurrent reads)

Import

  • Load SQL dump into a fresh or existing database
  • Update sync_state to reflect imported range
  • Validate: no duplicate heights, namespace consistency
  • Transaction-wrapped for atomicity (rollback on error)

Snapshot (alternative)

  • Since it's SQLite, a raw file copy of the .db file is also valid
  • Document the "stop, copy, start" approach as the simplest option
  • apex snapshot --output ./backup/ could do a safe SQLite backup via the backup API

References

  • Design doc: test_plan.md — Bulk Import section
  • SQLite online backup API: sqlite3_backup_init

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions