sqlite-online-backup · shipping · also SQLite backup API, sqlite3_backup

SQLite Online Backup API

The SQLite Online Backup API copies one named database between distinct connections using an explicit initialization, page-copy and cleanup sequence.

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. [1]

On 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. [4] [3]

In 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. [6] [7]

In 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. [8] [10]

With 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. [9] [11]

Completed 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. [12]

Relations

related
Backup, Backup verification, Restore test, SQLite WAL end mark, Rollback journal, Storage snapshot, SQLite rowid, SQLite AUTOINCREMENT, Checkpoint starvation, SQLite transaction state, SQLite serialization, SQLite snapshot handle

Limitations

  • Serialization can retain a writer's uncommitted rows; it is a different export path. [13]
  • A writable WAL or initialized-memory destination can reject a page-size mismatch with SQLITE_READONLY; read back effective settings before copying. [1] [14]
  • 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. [15]

Citations

  1. SQLite C API: Online Backup API. (accessed 2026-10-21)
  2. SQLite version-3.45.1: backup.c, step status and finish return. (accessed 2026-10-21)
  3. Hesela: SQLite lock-abandonment experiment and controls. (accessed 2026-10-17)
  4. Hesela: native API experiment receipt and runtime identity. (accessed 2026-10-17)
  5. Hesela: backup progress, writer identity and retained source views. (accessed 2026-10-21)
  6. Hesela: 21 native backup-progress observations, build identity and hashes. (accessed 2026-10-21)
  7. Hesela: two-build source-read retention experiment, derived summary and receipt hashes (accessed 2026-10-21)
  8. SQLite: PRAGMA journal_size_limit, retained file size and reset (accessed 2026-10-21)
  9. SQLite: per-schema transaction state (accessed 2026-10-21)
  10. Hesela: source-read ownership after backup cleanup, method and limitations (accessed 2026-10-21)
  11. Hesela: native recovery-copy controls, exact build scope and source synthesis (accessed 2026-10-23)
  12. Hesela: controlled SQLite serialization and source-commit provenance (accessed 2026-11-03)
  13. SQLite: PRAGMA page_size and deferred conversion (accessed 2026-11-29)
  14. Hesela: native SQLite destination-compatibility observations, method and reproduction (accessed 2026-11-29)

Further reading

  1. SQLite: Using the Online Backup API. (accessed 2026-10-21)
Sources & caveats
  • Constructed data; native C API calls through Python ctypes. Full build identity and hashes are in the receipt. [5]
  • 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. [15]

JSON: /data/terms/sqlite-online-backup.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. SQLite Online Backup API. Hesela. 2026-11-29. https://hesela.dev/terms/sqlite-online-backup/