# SQLite backup destination compatibility

Controlled native observations, 29 November 2026. This packet accompanies
[Hesela's backup-verification analysis](https://hesela.com/analyses/backup-verification-is-not-a-restore-test/)
and [Online Backup API definition](https://hesela.dev/terms/sqlite-online-backup/).
It reproduces documented behavior, not a newly discovered defect.

## Result

An initialized destination can accept ordinary UPDATE statements yet reject a
backup copy with SQLITE_READONLY because its page size differs from the source
and it uses WAL journaling or in-memory storage. In the retained mismatch cases,
the destination kept its old, structurally valid rows. Counts matched the source;
full ordered row digests did not. Both backup counters were zero on the failure
path. Neither that progress reading nor integrity_check established completion.

The matrix covers 15 target profiles, source sizes 4096 and 8192 bytes, DELETE
and WAL sources, two repetitions and two recorded builds (3.45.1 and 3.54.1):
240 constructed runs, not 240 sampled incidents. Exact build identifiers,
compile options and library hashes are in the two observations files.
No distribution or upstream library is bundled or recommended for installation.

## Files and reproducibility

- [summary.json](summary.json): all 15 derived groups and input hashes.
- [matrix.md](matrix.md): generated full comparison table.
- [observations-system.json](observations-system.json) and
  [observations-upstream.json](observations-upstream.json): retained native results.
- [probe.py](probe.py), [summarize.py](summarize.py),
  [render_matrix.py](render_matrix.py), [test_probe.py](test_probe.py):
  collector, derivation and 18 regression tests.
- [sources.json](sources.json) and [collect_sources.py](collect_sources.py):
  seven primary-source receipts and optional retrieval utility.
- [publication-table.json](publication-table.json): eight selected groups used
  in the article, with their original profile identifiers.
- [manifest.json](manifest.json): file hashes and research commit provenance.
- [evidence.zip](evidence.zip): standalone code, receipts and these instructions.

Extract the archive into an empty directory. Linux, Python 3 and an installed
SQLite shared library are required; no Python package installation, Git checkout,
database service or network is needed for the tests.

```sh
python3 -B -m unittest -v test_probe.py
python3 -B -O -m unittest -v test_probe.py
python3 -B probe.py --output replay.json
python3 -B summarize.py --output regenerated-summary.json
```

Use --library /absolute/path/libsqlite3.so for the collector, or SQLITE_LIBRARY
for the tests, to select an existing library. Outputs must not already exist.
The test suite executes 60 fresh native configurations and checks the frozen
receipts; reruns are not pooled into the original 240. Divergence on a different
build is evidence to investigate, not a reason to change expected results.

All fixtures are disposable temporary databases. The script accepts no source
or destination database path. Each initialized target has 12 target-marked rows;
sources have 12 different source-marked rows. Before/after rolled-back UPDATE
controls establish ordinary writability. The driver records effective settings,
step/finish returns, row hashes and integrity, and reopens file targets read-only.
It never queries a destination connection while its backup handle is active.

## Distinctions that matter

Matching WAL/memory targets and mismatched DELETE-mode file targets completed.
Fresh memory could adapt; initialized memory could not. A schema-empty file
already in WAL mode rejected the mismatch, so absence of user tables does not
mean an uninitialized pager. A successful page_size setter did not change the
effective size in the tested WAL/initialized-memory cases, even with VACUUM.

Changing an isolated WAL target to DELETE allowed copying. With a WAL source,
that destination later reported WAL again: retain pre-copy settings, not only
post-copy settings. This is a diagnostic control, not advice to alter a live
service. A truly read-only target returned the same primary error, but failed
the UPDATE controls that the writable mismatch targets passed.

The [API contract](https://sqlite.org/c3ref/backup_finish.html) enumerates these
READONLY causes and treats the error as fatal for that backup handle.
[Connection mode](https://sqlite.org/c3ref/db_readonly.html) answers whether a
named database is read/write, not whether it can accept a particular image.
[Page-size rules](https://sqlite.org/pragma.html#pragma_page_size),
[WAL limitations](https://sqlite.org/wal.html) and the
[empty-memory example](https://sqlite.org/backup.html) explain the state boundary.
The pinned backup.c implementations linked in sources.json explain page-size
negotiation and the zero-initialized progress counters.

## Acceptance and limits

Record target kind, initialization history, source/target effective page sizes,
pre-copy journal mode, named schemas, terminal step and finish returns.
Then verify the required data identity and application behavior in an isolated
staging destination. READONLY is not by itself a reason to chmod a production file.

One host, two differently configured builds, small fixed main-schema fixtures.
No concurrency, custom VFS, encryption, attached/TEMP schema, crash, power loss,
performance, RTO, independent peer replication or field-rate claim. Agreement
does not isolate a version effect. Memory results cover the tested initialization
paths, not every possible construction.

Research originates in commit 4a5d3a3bf1df1b7ad49fc3b3dc60ec2c8078a2a3.
Scientific code and retained receipts are byte-preserved. This publication adds
a generated selection, portable packaging and explanatory navigation.
SQLite documentation and source are linked, not redistributed.
