# When the historian store file does not open

> The historian's store file did not open at start. Tell a locked file from a damaged one, repair a file a checkpoint cut short (checked on a copy, e-signed, the original kept, the history complete), or set a damaged file aside from System Health (an administrator signs it; the file is renamed, never deleted, and the points waiting go to a new store), then restore the history before it offline with historian-restore --snapshot --keep-current.

Product: eaxScada · Type: How-to guide · Editions: Starter, Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/how-to/when-the-historian-store-file-does-not-open/
Verified against commit 23c5c8f.

## Goal

The historian's columnar store is one file, `scada_history.duckdb` in the historian folder. When it does not open at start, eaxScada does not stop and loses nothing: the new points wait in the [spool](/docs/eaxscada/explanation/historian/#25e-when-the-store-does-not-take-writes-the-spool), and the store is tried again every minute. The file is never touched by itself.

This guide tells you what to do next:

1. **Find out why the file does not open.** A file that is only in use by another process is not damaged, and opens again once that process lets go.
2. **If a checkpoint was cut short, repair it** (through the API for now): a verified copy takes the file's place, the original is kept, and the history stays complete.
3. **If it is damaged otherwise, set it aside** from System Health: the file is renamed and kept, a new empty store opens, and the points waiting are written to it.
4. **Restore the history from before it** from the nightly snapshot, offline, keeping the points written since.

Nothing in this guide deletes a file, and nothing is ever repaired or set aside automatically. It applies to **stores without encryption at rest**: an encrypted store that does not open stops the server (it fails closed), and it is never repaired or set aside.

## Before you start

- **You must be an administrator**, signed in to the studio, on a desktop or a tablet. On a phone the studio does not show System Health. An API token, the AI co-pilot or an eaxCloud remote session cannot set the store aside.
- **Check that the store did not open at start.** The system alarm `ALM-SYS-HISTORIAN-STORE-DOWN` is active, and System Health's **Logging** row says "store not taking writes - points kept in the spool". The set-aside is offered only in this case. A store that opened and later fails writes is handled by the spool and the retry: there is nothing to set aside.
- **Find the newest snapshot made before the store stopped opening.** The nightly snapshot is in `./data/backup/historian` by default (`historian-.duckdb`). It is what brings the old history back. The snapshot runs once a day: restarting the server while you work on this does not take new snapshots, nor prune the ones of the days before.

## 1. Open the check of the file

1. Open **System Health** and find the **Historian storage** card.
2. While the store did not open at start, the row **Store file** says "does not open". Administrators see **Set the store aside…** next to it.
3. Click it. The dialog checks the file before it offers anything.
[Image: System Health, section PC resources and historian storage, while the store file did not open at start. In the Historian storage card, Logging says "store not taking writes - points kept in the spool"; Spool says "118 points waiting (10 kB of 2.0 GB)" with the store's open error, "IO Error: Corrupt database file: computed checksum ... does not match stored checksum ... in block at location 4096"; and the row "Store file: does not open" carries the button "Set the store aside…".]
[Image: System Health, section PC resources and historian storage, while the store file did not open at start. In the Historian storage card, Logging says "store not taking writes - points kept in the spool"; Spool says "118 points waiting (10 kB of 2.0 GB)" with the store's open error, "IO Error: Corrupt database file: computed checksum ... does not match stored checksum ... in block at location 4096"; and the row "Store file: does not open" carries the button "Set the store aside…".]

The store did not open at start: the points wait in the spool, and an administrator can check the file.
## 2. Read what the check found

The check looks at the file itself, then at the store's own open error:

| Check | What it means | What happens |
|---|---|---|
| **in use by another process (not damaged)** | Another process holds the file: a second eaxScada on the same folder, a backup tool, an antivirus scan. On Windows the file is open without sharing; on Linux it is locked, and the dialog names the process's PID. | **Refused.** Stop that process or wait for the scan. The store is taken back at the next retry, within a minute. |
| **cannot be read by eaxScada (a permission)** | eaxScada's own account may not open the file for reading and writing. That is not damage. | **Refused.** Give the service account access to the file. |
| **opens now: taken back** | The file opened when it was checked. | Nothing to set aside: the store is used again and the points waiting are written to it. |
| **no store file** | The path is missing or is not a file. | **Refused.** The cause is elsewhere (the folder, the disk). |
| **this eaxScada does not open the store file and leaves it as it is** | The file is in a newer format than this eaxScada opens: a newer eaxScada wrote it. That is not damage. System Health's [Database stores](/docs/eaxscada/reference/metrics/#database-stores) shows the store **refused**. | **Refused.** Start the newer eaxScada again, or restore the backup taken before the upgrade. Do not delete the file. |
| **damaged: it does not open** | The file is not locked, eaxScada can read it, and it still does not open. The **Header** line says whether it is "a store file (its blocks are damaged)" or "not a store file". | The set-aside is offered. The diagnosis also says whether the file can be [repaired](#2a-repair-a-file-a-checkpoint-cut-short) instead. |

**Why a locked file is never set aside:** it is not damaged. Setting it aside would hand the other process a renamed file, and give the server an empty store while the real history is fine.

For a damaged file, the dialog shows:

- the **store file** with its size, the **check**, the **open error**, the **header**, and the **write-ahead log** (`.wal`) when there is one: it is set aside with the file;
- the **points waiting** in the spool, and that they are written to the new store;
- **the rules:** the file (and its write-ahead log) is renamed to `scada_history.broken-.duckdb` and kept, never deleted; a new empty store opens in its place and the points waiting are written to it in order, none lost; the history before it is not in the new store until a snapshot is restored; a file only in use by another process is never set aside;
- **the signature:** the signer (you, read-only), the text you sign, an empty reason and an empty password.
[Image: The dialog "Set the historian store aside", "Signed with your password and a reason": a red note says "the store file is damaged: it does not open; it is not locked by another process and can be read". The card lists Store file scada_history.duckdb (3.0 MB); Check damaged: it does not open; the open error "IO Error: Corrupt database file: computed checksum ... does not match stored checksum ... in block at location 4096"; Header a store file (its blocks are damaged); Write-ahead log present (5.2 kB), set aside with it; and the points waiting, written to the new store. The four rules are beside it. Below, the Electronic signature section with the signer "Administrator (admin)" shown read-only, an empty reason, the text you sign, which names the file, its size, the open error, its .wal, the node, the new name scada_history.broken-.duckdb and the points waiting, and the password field. The buttons Cancel and Sign and set aside.]
[Image: The dialog "Set the historian store aside", "Signed with your password and a reason": a red note says "the store file is damaged: it does not open; it is not locked by another process and can be read". The card lists Store file scada_history.duckdb (3.0 MB); Check damaged: it does not open; the open error "IO Error: Corrupt database file: computed checksum ... does not match stored checksum ... in block at location 4096"; Header a store file (its blocks are damaged); Write-ahead log present (5.2 kB), set aside with it; and the points waiting, written to the new store. The four rules are beside it. Below, the Electronic signature section with the signer "Administrator (admin)" shown read-only, an empty reason, the text you sign, which names the file, its size, the open error, its .wal, the node, the new name scada_history.broken-.duckdb and the points waiting, and the password field. The buttons Cancel and Sign and set aside.]

Only a file that is not locked, is readable and still does not open can be set aside. The signature names the file as checked.
## 2a. Repair a file a checkpoint cut short

A power loss or a killed process during a checkpoint can leave a store file that does not open although its data is intact: one block's checksum is wrong. The open error then reads "computed checksum … does not match stored checksum … in block at location …". Such a file can be repaired instead of set aside, and **no snapshot restore is needed afterwards**.

If the store does not open because a checkpoint was cut short, eaxScada checks a copy block by block, recomputes the one wrong checksum, reads every table of the copy and compares its daily row counts with your latest snapshot. Only a copy that passes is offered. An administrator repairs it with an electronic signature. The original file is kept as `scada_history.torn-.duckdb`, a journal is written next to it, and the audit trail records both files' SHA-256. Your history stays complete. Nothing is ever repaired automatically, and an encrypted store is never repaired.

:::note[The repair button follows]
System Health does not have a Repair button yet: it follows in a later release. Until then the repair is done through the [Historian store API](/docs/eaxscada/reference/historian-store-api/#repair-a-file-a-checkpoint-cut-short), by a signed-in administrator, with the same rules as the set-aside: never an API token, the AI co-pilot or a remote session.
:::

### Read whether a repair is possible

**The server log says it first.** When the store does not open at start, the server reads the file's headers and metadata blocks (only reads them) and logs at once one of two lines: a warning "historian store at start: may be repairable (a checkpoint cut short)", with the block and the three API routes to use, or an information line "historian store at start: not a checkpoint cut short, so not repairable (the set-aside is offered in System Health)". The start does not wait for this.

`GET /api/historian/store` carries `diagnosis.repair` while the store is `broken`. Its `state`:

| State | What it means | What next |
|---|---|---|
| `candidate` | The file's headers and the chains of metadata blocks hold, and exactly one metadata block has a wrong checksum: the trace of a checkpoint cut short. `evidence` names the block and its location. Only the file was read. | Start the check of a copy. |
| `checking` | A copy of the file and its write-ahead log is being made next to it (`scada_history.repair-.duckdb`), checked block by block, patched and verified. | Wait, and read the diagnosis again. |
| `verified` | The patched copy opened read-only, every table read to its end, and no day of the latest snapshot holds more rows than the copy. The answer adds `repair_meaning`, the text you sign. | Repair, e-signed. |
| `refused` | The copy did not pass a rule or did not verify; `why` says which. The copy is removed. | Only the set-aside. |
| `not_repairable` | The file is not a checkpoint cut short: another kind of damage, or not a store file. | Only the set-aside. |

**The comparison with the snapshot.** Days older than the copy's first day (a retention purge since the snapshot) and that first day itself are not compared. With no snapshot to compare with, the check says so in its `verification`, and the other checks still apply.

A file that changes, a set-aside or the store opening drops the check and its copy.

**The check runs apart from the server.** The copy and the snapshot are read in a separate process of the eaxScada program that the server starts for the check, read only, one file at a time, each for at most 6 hours (a large store takes time). If that process crashes, hangs, stops with an error or gives no valid answer, the repair is `refused` with the reason, and the server keeps running.

**A restart during a check leaves no copy behind.** At the next start the server deletes the copies a check left in the store's folder (`scada_history.repair-.duckdb` and its `.wal`, those names only) and logs each deletion. Such a copy was never put in place; start a new check. The kept originals (`scada_history.torn-*`) and every other file stay.

### Repair

1. **Start the check:** `POST /api/historian/store/repair/check` with the diagnosis's `hash`. The answer is `202` with the state `checking`. It needs free space for a copy of the file and its write-ahead log, plus 256 MB, above the disk guard's critical line.
2. **Read the diagnosis again** until `repair.state` is `verified`, then read `repair_meaning`.
3. **Sign:** `POST /api/historian/store/repair/sign` with your password, a reason and the verified repair's `hash`. The answer is a one-time ticket, bound to this repair and signed under the decision `historian_store_repair` (`GET /api/historian/store` names it in `repair_decision`): a set-aside ticket does not repair, and a repair ticket does not set aside.
4. **Repair:** `POST /api/historian/store/repair` with the `hash`, the reason and the ticket.

What happens, in this order:

1. **The original and the copy are checked again**: the same size and time, still the same wrong block. If either changed, nothing happens (`409 changed`): check again.
2. **A journal is written** next to the file: `scada_history.torn-.duckdb.repair.json`, with both SHA-256, the block and the verification.
3. **The audit record comes first:** `HISTORIAN_STORE_REPAIRED`, with your signature, the file, its open error, the block, the verification, and both files' SHA-256. If it cannot be written, the journal is removed and nothing changes (`503 AUDIT_NOT_WRITTEN`).
4. **The original is renamed, never deleted:** `scada_history.duckdb` becomes `scada_history.torn-.duckdb`, with its `.wal`. The verified copy and its `.wal` take its place. No file is overwritten.
5. **The store opens** (if not at once, at the next retry within a minute), its write-ahead log replays the commits acknowledged before the crash, and the points waiting in the spool are written to it in order. `ALM-SYS-HISTORIAN-STORE-DOWN` clears once the store takes writes.

Trends show the whole history again: there is nothing to restore. **Keep the original** (`scada_history.torn-.duckdb`, its `.wal` and its `.repair.json`) as evidence until the repaired history checks out; eaxScada never deletes it.

A signed repair that did not go ahead after its ticket was redeemed is recorded as `HISTORIAN_STORE_REPAIR_REFUSED`, with the cause. The refusals are in the [Historian store API](/docs/eaxscada/reference/historian-store-api/#refusals-of-the-repair).

## 3. Sign and set the file aside

When the diagnosis's repair is `not_repairable` or `refused`, or you do not repair, set the file aside:

1. Type a **reason** and your **password**. Neither is filled in for you.
2. Click **Sign and set aside**.

What happens, in this order:

1. **The file is checked again.** If it changed since the dialog showed it (another size or time, another error), or is now locked or opens, nothing happens: the dialog says why, and you review it again.
2. **The audit record comes first.** `HISTORIAN_STORE_SET_ASIDE` is written with your signature: the file, its size and time, the open error and the new name. If it cannot be written, nothing changes.
3. **The file is renamed, never deleted:** `scada_history.duckdb` becomes `scada_history.broken-.duckdb`, and its write-ahead log becomes `scada_history.broken-.duckdb.wal`. No file is overwritten. If the write-ahead log cannot be renamed, the store file is put back: nothing changed.
4. **A new empty store opens** at the old place, and **the points waiting in the spool are written to it** in order. None is lost. `ALM-SYS-HISTORIAN-STORE-DOWN` clears once the store takes writes.
5. A record of the set-aside, `scada_history.set-aside.json`, is written in the historian folder. It stays until a snapshot restore removes it.

From now on, trends show the points written since the set-aside. The history before it shows again after the restore (step 5). CSV history from before the columnar store reads as before.

**The scheduled export and the nightly snapshot start afresh on the new store.** The errors they recorded while the store did not open (for example "historian inventory: … Corrupt database file …") are cleared, and both run again at the next minute's check, against the new store. Before, System Health showed "Scheduled export: failing" until the next hourly retry.

**System Health's "Export error" row shows the short cause**: the store file's name, without its folder or the database driver's prefix, as the Spool row does. The full error stays in the server log and in `GET /api/historian/storage` (`last_error`, with `last_error_short` beside it).

## 4. See what is left to do

After the set-aside, System Health's Historian storage card shows **Store set aside** with the date and the name of the kept file: "restore the latest snapshot". Administrators get **How to restore…**:

- the newest snapshot **made before the set-aside** (a later nightly snapshot holds only the new store). The dialog says "The newest snapshot made before the set-aside is historian-\.duckdb.", or, when there is none, "No snapshot of this historian made before the set-aside was found: restore one from your backups.";
- the exact command, with a **Copy** button;
- a link to the restore in the documentation.
[Image: System Health, Historian storage card after the set-aside: Logging is back to "writing", and the row "Store set aside" reads "on 2026-11-10: kept as scada_history.broken-20261110T185529Z.duckdb; restore the latest snapshot", with the button "How to restore…". The columnar store file is the new one (12 kB).]
[Image: System Health, Historian storage card after the set-aside: Logging is back to "writing", and the row "Store set aside" reads "on 2026-11-10: kept as scada_history.broken-20261110T185529Z.duckdb; restore the latest snapshot", with the button "How to restore…". The columnar store file is the new one (12 kB).]

After the set-aside: the new store takes the points, and System Health says what is left to do.
[Image: The dialog "Historian store", "Set aside: restore the history before it": "Store set aside on 2026-11-11 15:28:49 UTC by admin: the broken file is kept as scada_history.broken-20261111T152849Z.duckdb." "The newest snapshot made before the set-aside is historian-20261111T152822Z.duckdb." "Stop eaxScada, run the command once without --confirm (a dry run), then with it; the points written since stay (--keep-current)." The command eaxscada historian-restore --snapshot "C:\eaxscada\data\backup\historian\historian-20261111T152822Z.duckdb" --keep-current --confirm with a Copy button, the link "Restore from a snapshot (documentation)", and Close.]
[Image: The dialog "Historian store", "Set aside: restore the history before it": "Store set aside on 2026-11-11 15:28:49 UTC by admin: the broken file is kept as scada_history.broken-20261111T152849Z.duckdb." "The newest snapshot made before the set-aside is historian-20261111T152822Z.duckdb." "Stop eaxScada, run the command once without --confirm (a dry run), then with it; the points written since stay (--keep-current)." The command eaxscada historian-restore --snapshot "C:\eaxscada\data\backup\historian\historian-20261111T152822Z.duckdb" --keep-current --confirm with a Copy button, the link "Restore from a snapshot (documentation)", and Close.]

How to restore: the newest snapshot made before the set-aside, and the command to run with the server stopped.
**The snapshots made before the set-aside are kept.** While the set-aside record is there, the nightly snapshot never deletes them, and they do not count towards `historian.snapshot.keep`. The new store's snapshots are pruned as usual.

## 5. Restore the history before the set-aside

With the server stopped, as the user that runs it, from its working folder:

1. **Run a dry run.** It writes nothing:

   ```sh
   eaxscada historian-restore --snapshot "./data/backup/historian/historian-.duckdb" --keep-current
   ```

   It checks the snapshot, says that the store was set aside, and prints what it would do. For example:

   ```text
   Historian snapshot historian-20261110T185348Z.duckdb verified: 29536 rows, made 2026-11-10T18:53:48Z.
   The store was set aside (scada_history.broken-20261110T185529Z.duckdb, 2026-11-10T18:55:29Z): this restore brings the history before it back.
   Dry run. A restore with --confirm would:
     copy <historian folder> to <historian folder>.restore-<time> and put the snapshot in place of its columnar store
     append the 682 rows of the current store after the snapshot's, in their write order (they are later writes: they win where both hold a tag and timestamp), checked by count and checksum
     history written between the snapshot and the current store's first row is not in either
     keep the current historian, unchanged, as <historian folder>-before-restore-<time>, and record the restore in the audit trail
   Nothing was written. Run again with --confirm to restore.
   ```

2. **Run the restore:**

   ```sh
   eaxscada historian-restore --snapshot "./data/backup/historian/historian-.duckdb" --keep-current --confirm
   ```

3. **Start the server**, and open the trends of a few tags over the days before the set-aside.

What `--keep-current` does:

- **The snapshot's history takes the store's place, and the rows of the current store (the points written since the set-aside) are appended after it**, in their write order. They are later writes: where both hold a tag and timestamp, the current store's value wins.
- **They are checked before the swap,** by count and by checksum. If they do not match, the restore stops and the live history is unchanged.
- **The previous historian folder is kept** beside the restored one, unchanged (`<historian folder>-before-restore-<time>`), as for every restore. The record `HISTORIAN_SNAPSHOT_RESTORED` names the rows kept. The broken file stays in the historian folder.
- **The set-aside record is removed:** System Health no longer shows "Store set aside", and the nightly snapshot prunes as usual again.

:::caution[History in neither file]
The history written **between the snapshot and the set-aside** is in neither the snapshot nor the new store. It is only in the broken file. A snapshot made at 01:30 and a set-aside at 14:00 leave that day's history from 01:30 until the store stopped opening out of the restored store. The dry run says so.
:::

**Without `--keep-current`** the restore replaces the whole store with the snapshot's, as before, and the points written since the set-aside are dropped. The dry run says so: "the current store holds 682 rows; --keep-current keeps it".

**Keep the broken file** (`scada_history.broken-.duckdb` and its `.wal`) until the restored history checks out. eaxScada never deletes it.

## When the server refuses

| Answer | Why | What to do |
|---|---|---|
| `401` or `403` | Not a signed-in administrator, an API token, the AI co-pilot; a wrong password ("signature refused"). | Sign in as an administrator, and type your own password. |
| `409` locked | The file is in use by another process: not damaged. | Stop that process or wait; the store is taken back at the next retry. |
| `409` unreadable | eaxScada cannot open the file for reading and writing (a permission), or could not check it. | Give the service account access to the file. |
| `409` opens_now | The file opened when it was checked: it is used again. | Nothing to do. |
| `409` missing | There is no store file at the path. | Look at the folder and the disk. |
| `409` not_offered | The store did not fail to open at start (or is open). | Nothing to set aside. |
| `409` changed | The file or its check changed since the dialog showed it. | Review it again and sign again. |
| `409` busy | A CSV history import call or a historian snapshot is in progress. | Try again in a moment. |
| `409` low_disk | Free space is under about twice the spool's size plus 256 MB, above the disk guard's critical line. | Free space on the historian's disk. |
| `503` `AUDIT_NOT_WRITTEN` | The audit record could not be written. **Nothing changed.** | Check the audit folder's disk and access. |

A signed set-aside that did not go ahead is recorded as `HISTORIAN_STORE_SET_ASIDE_REFUSED`, with the cause. The e-signature decision is `historian_store_set_aside`. The routes are in the [Historian store API](/docs/eaxscada/reference/historian-store-api/).

## The CSV history import after a set-aside

The [CSV history import](/docs/eaxscada/how-to/import-csv-history-into-the-store/) kept its state in the store that was set aside. The new store shows it "not started", and a new plan lists the CSV history still on disk. The CSV days already imported and deleted are in the broken file and in the snapshot: the restore brings them back.

## See also

- [Historian: when the store does not take writes, the spool](/docs/eaxscada/explanation/historian/#25e-when-the-store-does-not-take-writes-the-spool)
- [Historian: the nightly snapshot](/docs/eaxscada/explanation/historian/#the-nightly-snapshot) and [restore from a snapshot](/docs/eaxscada/explanation/historian/#restore-from-a-snapshot)
- [Historian store API](/docs/eaxscada/reference/historian-store-api/)
- [Command-line reference: historian-restore](/docs/eaxscada/reference/generated/cli/#scada-server-historian-restore)
