{
  "slug": "spojna-kopia-bazy-podczas-zapisu",
  "ranking_id": "NC01",
  "edition": "1.0",
  "date": "2026-11-19",
  "series": {
    "pl": "AI na własnej stacji",
    "en": "AI on your own workstation"
  },
  "number": 7,
  "title": {
    "pl": "Spójna kopia bazy podczas zapisu",
    "en": "A consistent database backup during writes"
  },
  "intro": {
    "pl": "Kopiowanie zakończone. Teraz sprawdź, którą rewizję danych rzeczywiście odzyskasz.",
    "en": "Copying has finished. Now check which data revision you can actually recover."
  },
  "sources": [
    {
      "title": "File-package restoration trial",
      "url": "https://www.l00p.ai/zasoby/serie/kopia-zapasowa-przechodzi-probe-odtworzenia/",
      "access": "public"
    },
    {
      "title": "Original fictional NC01 SQLite backup trial, 19 November 2026",
      "access": "internal",
      "kind": "18 checks; two connections; single-thread controlled interleaving; DELETE journal; no WAL/crash/load trial"
    },
    {
      "title": "SQLite Online Backup overview",
      "url": "https://www.sqlite.org/backup.html",
      "access": "public"
    },
    {
      "title": "SQLite Online Backup C interface",
      "url": "https://www.sqlite.org/c3ref/backup_finish.html",
      "access": "public"
    },
    {
      "title": "SQLite backup hazards",
      "url": "https://www.sqlite.org/howtocorrupt.html",
      "access": "public"
    },
    {
      "title": "Python 3.11 sqlite3.Connection.backup",
      "url": "https://docs.python.org/3.11/library/sqlite3.html#sqlite3.Connection.backup",
      "access": "public"
    }
  ],
  "checked_at": "2026-11-19",
  "evidence_scope": {
    "pl": "18 kontroli jednej lokalnej próby: jawny zapis między krokami kopii i odczyt po ponownym otwarciu. Bez WAL, awarii i obciążenia produkcyjnego.",
    "en": "18 checks within one local trial: an explicit write between backup steps and read after reopening. No WAL, crash or production workload."
  },
  "update_trigger": {
    "pl": "Zmiana metody kopii, trybu dziennika, wersji wykonawczej lub oczekiwanych rekordów.",
    "en": "A change to backup method, journal mode, runtime version or expected records."
  },
  "ai": {
    "authoring": "Codex",
    "source_selection": "Codex",
    "human_review": "post-publication withdrawal by Lech R. Rustecki"
  },
  "interactive": "live-backup-text",
  "credits": {
    "pl": "Opracowanie i wybór: agent Codex. Brak niezależnej recenzji drugiego modelu. Kontrola człowieka: możliwość wycofania po publikacji.",
    "en": "Prepared and selected by a Codex agent. No independent second-model review. Human oversight: withdrawal after publication."
  },
  "history": {
    "pl": "Historia: 1.0 — własna próba migawki SQLite, 19.11.2026.",
    "en": "History: 1.0 — original SQLite snapshot trial, 19 November 2026."
  },
  "schema_version": 1,
  "language": "en",
  "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/",
  "markdown_sha256": "234522ee26847d6fb7664662b04dc11beff08aada4844bc1e22dd594fb9db476",
  "sections": [
    {
      "id": "rozdzial-01",
      "title": "01 / A file copy leaves questions open",
      "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/#rozdzial-01",
      "markdown": "You have confirmation that a database backup exists. Which data version will you recover if someone committed a change during copying? Our original trial demonstrates an acceptance method: a separate destination, a completed backup operation, reopening and comparing records against expectations written beforehand. It extends the [file-package restoration trial](/en/resources/series/kopia-zapasowa-przechodzi-probe-odtworzenia/), which explicitly excluded databases.\n\nOn 19 November 2026 we ran a local demonstrator using Python 3.11.11 and SQLite 3.47.1. All data is fictional. The source remained open; a second connection performed a write between backup steps. We ran neither a parallel workload nor a production-system trial."
    },
    {
      "id": "rozdzial-02",
      "title": "02 / A state that can be checked",
      "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/#rozdzial-02",
      "markdown": "At revision 1, record A holds 400 and B holds 600. The total is 1000. A separate table stores the revision number. We added 128 filler records of 2000 characters each so copying required multiple steps. The database had 69 pages; it used DELETE journaling, without WAL mode.\n\nFirst we backed up state 1. Then we started a second backup through `Connection.backup(pages=1)`. In the progress callback, with 68 pages remaining, the second connection executed one transaction: A became 350, B became 650 and the revision became 2. After commit, copying proceeded to its next step. This is explicit interleaving in one thread, not evidence of instructions executing simultaneously."
    },
    {
      "id": "rozdzial-03",
      "title": "03 / Accept the completed snapshot",
      "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/#rozdzial-03",
      "markdown": "![Revision 2 is committed between backup steps: A=350, B=650. The completed backup retains revision 2 after the source changes to revision 3. A deliberately incorrect copy totals 950.](https://www.l00p.ai/wydawnictwo/spojna-kopia-bazy-podczas-zapisu/kopia-en-v1.svg)\n\n```text\nbefore:          revision 1 | A=400 | B=600\nduring backup:   COMMIT 2   | A=350 | B=650\nfinished backup: revision 2 | A=350 | B=650 | total=1000\nlater source:    revision 3 | A=300 | B=700\nretained backup: revision 2 | A=350 | B=650\n```\n\nCopying reached SQLITE_DONE. We closed the destination connection and reopened the database read-only. The revision, both records and filler count matched; the integrity check returned `ok`. After a later commit of revision 3, the source held 300 and 700 while the completed backup still held 350 and 650. Its bytes remained unchanged. The first backup retained revision 1.\n\nThis result does not justify promising that every backup represents its starting instant. The [SQLite Online Backup interface](https://www.sqlite.org/c3ref/backup_finish.html) allows copying to restart after another connection changes the source. In our controlled run, the completed snapshot contained revision 2. Acceptance requires explicitly establishing the recovered state."
    },
    {
      "id": "rozdzial-04",
      "title": "04 / Valid structure, incorrect records",
      "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/#rozdzial-04",
      "markdown": "We made a separate control variant from the closed, correct backup. We deliberately changed B from 650 to 600, retaining revision 2 and A=350. SQLite could still read the database, and `integrity_check` returned `ok`. Exact record comparison and a total of 950 instead of 1000 rejected this variant.\n\nThis was not damage caused by the backup API. It was a deliberately altered copy, demonstrating the difference between database structural integrity and compliance with the data contract. The total alone is also insufficient: other incorrect pairs could add up to 1000. Acceptance therefore compared the actual records and revision too.\n\nIn total, 18 checks passed within one trial, including expected rejection of the deliberate error. We preserved the pre-execution protocol, code, inputs, four databases, progress callback trace, results and artifact hashes. These are not 18 independent experiments."
    },
    {
      "id": "rozdzial-05",
      "title": "05 / Your backup acceptance card",
      "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/#rozdzial-05",
      "markdown": "```text\nDatabase scope and backup method:\nSeparate destination, without overwriting the source:\nExpected revision and actual records:\nConfirmation that the operation completed:\nRead after closing and reopening:\nStructural integrity and matching data:\nDeliberate error detected by acceptance:\nResponsible person, date, remaining gaps:\n```\n\nChoose a check that represents the work you need to recover. This demonstrator reads records; it does not restore an application. We did not copy a live database's raw file to induce corruption. The [SQLite documentation on backup hazards](https://www.sqlite.org/howtocorrupt.html) explains why such copying needs coordination with the database mechanism; the [Online Backup overview](https://www.sqlite.org/backup.html) presents backup methods."
    },
    {
      "id": "rozdzial-06",
      "title": "06 / Limits, sources and corrections",
      "url": "https://www.l00p.ai/en/resources/series/spojna-kopia-bazy-podczas-zapisu/#rozdzial-06",
      "markdown": "The trial covered one small local database and a controlled write between steps. It did not test WAL, process interruption, power failure, performance, recovery time, acceptable data loss, encryption or a second location. It did not check a search service, attachments or services outside this database. Reading recovered records does not establish organisation-wide disaster-recovery readiness.\n\nWe read [Python 3.11: Connection.backup](https://docs.python.org/3.11/library/sqlite3.html#sqlite3.Connection.backup) and the cited SQLite sources on 19 November 2026. The current documentation revision does not change the runtime version used in the trial. Codex created the data, script, PL/EN text and static diagram, performing the AI-agent roles of editorial, management and review. There was no independent second-model review. No third-party records or media were used; ASCII provides a text equivalent of the diagram.\n\nA change to the backup method, journal mode, runtime version or expected records requires renewed acceptance. What specific work can you recover from your latest backup, and how will you recognise the right state?"
    }
  ],
  "media": [
    {
      "url": "https://www.l00p.ai/wydawnictwo/spojna-kopia-bazy-podczas-zapisu/kopia-en-v1.svg",
      "kind": "diagram_in_code",
      "depicts_real_measurement": false
    }
  ]
}
