{
  "slug": "sqlite-online-backup",
  "term": "SQLite Online Backup API",
  "aliases": [
    "SQLite backup API",
    "sqlite3_backup"
  ],
  "definition": "The SQLite Online Backup API copies one named database between distinct connections using an explicit initialization, page-copy and cleanup sequence.",
  "note": "A step returning SQLITE_OK leaves pages to copy; SQLITE_DONE marks completion. Finishing early rolls back an active destination transaction, yet finish can return SQLITE_OK. Cleanup is not completion. [api]\n\nOn SQLite 3.45.1, no-step and partial-copy cancellation preserved old destination rows. All four reopened copies passed integrity_check with equal row counts; only completion matched the source. Lock abandonment returned BUSY from step and finish. This matches the pinned code but differs from the API prose. [experiment] [implementation]\n\nIn 21 controlled runs, other-connection writes repeatedly reset copying without BUSY; same-handle writes preserved progress. A pinned WAL view also preserved progress but copied generation 10 while the latest was 16. Copies completed after writers stopped. Six rounds are not an infinite-run measurement. [progress] [progress-data]\n\nIn 84 synthetic runs on two builds, complete and cancelled backups left a caller-owned read active. BEGIN alone did not retain a read between steps; BEGIN plus SELECT did. Per-schema transaction state separates them. [retention-data] [txn-state]\n\nWith that read retained, journal_size_limit=0 did not cap the live WAL. Ending it allowed truncation without closing the connection. Clean up only transactions owned by the operation, not unrelated pooled work. [journal-limit] [retention]\n\nCompleted copies can preserve an existing semantic inconsistency. In two tested builds, backups retained historical stale generated values and indexes; STORED cases still passed integrity_check. Check derivation, consumer queries and completeness separately from SQLITE_DONE. The newer build rejects the older BLOB mutation used to prepare these inputs. [recovery-copy]",
  "related": [
    "backup",
    "backup-verification",
    "restore-test",
    "sqlite-wal-end-mark",
    "rollback-journal",
    "snapshot",
    "sqlite-rowid",
    "sqlite-autoincrement",
    "checkpoint-starvation",
    "sqlite-transaction-state",
    "sqlite-serialization",
    "sqlite-snapshot-handle"
  ],
  "citations": [
    {
      "id": "api",
      "title": "SQLite C API: Online Backup API.",
      "url": "https://www.sqlite.org/c3ref/backup_finish.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "guide",
      "title": "SQLite: Using the Online Backup API.",
      "url": "https://www.sqlite.org/backup.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "implementation",
      "title": "SQLite version-3.45.1: backup.c, step status and finish return.",
      "url": "https://github.com/sqlite/sqlite/blob/version-3.45.1/src/backup.c",
      "accessed": "2026-10-21"
    },
    {
      "id": "experiment",
      "title": "Hesela: SQLite lock-abandonment experiment and controls.",
      "url": "https://hesela.com/analyses/backup-verification-is-not-a-restore-test/#sqlite-lock-abandonment",
      "accessed": "2026-10-17"
    },
    {
      "id": "receipt",
      "title": "Hesela: native API experiment receipt and runtime identity.",
      "url": "https://hesela.dev/research/sqlite-backup-abandonment.json",
      "accessed": "2026-10-17"
    },
    {
      "id": "progress",
      "title": "Hesela: backup progress, writer identity and retained source views.",
      "url": "https://hesela.com/analyses/backup-verification-is-not-a-restore-test/#sqlite-backup-progress",
      "accessed": "2026-10-21"
    },
    {
      "id": "progress-data",
      "title": "Hesela: 21 native backup-progress observations, build identity and hashes.",
      "url": "https://hesela.dev/research/sqlite-backup-progress/observations.json",
      "accessed": "2026-10-21"
    },
    {
      "id": "retention-data",
      "title": "Hesela: two-build source-read retention experiment, derived summary and receipt hashes",
      "url": "https://hesela.dev/research/sqlite-backup-retention/summary.json",
      "accessed": "2026-10-21"
    },
    {
      "id": "journal-limit",
      "title": "SQLite: PRAGMA journal_size_limit, retained file size and reset",
      "url": "https://sqlite.org/pragma.html#pragma_journal_size_limit",
      "accessed": "2026-10-21"
    },
    {
      "id": "txn-state",
      "title": "SQLite: per-schema transaction state",
      "url": "https://sqlite.org/c3ref/txn_state.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "retention",
      "title": "Hesela: source-read ownership after backup cleanup, method and limitations",
      "url": "https://hesela.com/analyses/backup-verification-is-not-a-restore-test/#sqlite-backup-retention",
      "accessed": "2026-10-21"
    },
    {
      "id": "recovery-copy",
      "title": "Hesela: native recovery-copy controls, exact build scope and source synthesis",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#recovery-copy",
      "accessed": "2026-10-23"
    },
    {
      "id": "serialization",
      "title": "Hesela: controlled SQLite serialization and source-commit provenance",
      "url": "https://hesela.com/analyses/backup-verification-is-not-a-restore-test/#sqlite-serialization",
      "accessed": "2026-11-03"
    },
    {
      "id": "page-size",
      "title": "SQLite: PRAGMA page_size and deferred conversion",
      "url": "https://sqlite.org/pragma.html#pragma_page_size",
      "accessed": "2026-11-29"
    },
    {
      "id": "destination-data",
      "title": "Hesela: native SQLite destination-compatibility observations, method and reproduction",
      "url": "https://hesela.dev/research/sqlite-page-compatibility/README.md",
      "accessed": "2026-11-29"
    }
  ],
  "provenance": [
    "Constructed data; native C API calls through Python ctypes. Full build identity and hashes are in the receipt. [receipt]",
    "The experiment tests controlled abandonment, not process crashes, power failures, whole-application recovery or source freshness.",
    "160 synthetic recovery configurations on recorded SQLite 3.45.1 and 3.54.1 builds; old-build seeds, closed files, two source journal settings. Not an incidence estimate or new vulnerability. Exact captures and reproduction package linked from the analysis.",
    "Destination compatibility: 240 constructed observations, 15 target profiles, 4096/8192-byte pages, DELETE/WAL sources, two repeats and recorded SQLite 3.45.1/3.54.1 builds. Ordinary-write and full-row controls; not a crash or field-rate study. [destination-data]"
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "Serialization can retain a writer's uncommitted rows; it is a different export path. [serialization]",
    "A writable WAL or initialized-memory destination can reject a page-size mismatch with SQLITE_READONLY; read back effective settings before copying. [api] [page-size]",
    "On the tested mismatch paths, zero remaining pages and integrity_check=ok coexisted with valid old target rows. Neither check proves that the intended copy completed. [destination-data]"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-29"
}
