# Genealogy retention, purge and archives

> Set how long each unit type's genealogy records are kept (at least 365 days, forever by default), plan a purge with a dry run, run the signed purge on site on the primary, and keep, list, download, restore and verify the encrypted purge archives with the recovery key.

Product: eaxScada · Type: How-to guide · Editions: Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/how-to/genealogy-retention-purge-and-archives/
Verified against commit 9d50b4d.

## Goal

Keep genealogy records as long as your regulations and customers require, and no longer. **By default nothing is ever removed.** A purge removes only what is past its retention, only after the records are archived and the archive is verified, and only with a signature.

## Before you start

- **A recovery key** set up in the backup settings ([Set up backups](/docs/eaxscada/how-to/checkpoints-fat-sat-and-reverting/#7-set-up-backups)), and its private file, downloaded when the key was made, kept somewhere safe. Without the key a purge is refused; without the private file the archives cannot be read.
- An **Administrator, on site**, to set the retention.
- A **Process_Supervisor or above, with `genealogy.write`, on site**, to run the purge.
- On a high availability pair: the purge runs on the **primary**.

## 1. Set the retention per unit type

Open **Genealogy > Retention and purge**. The **Retention by unit type** grid lists each unit type with **Kept for** (*Forever* by default).

1. Choose **Set** on a type and enter a period of at least 365 days: years (`10y`, a year counted as 365 days) or days (`3650d`). **Keep forever** removes the period.
2. Choose **Save settings** (Administrator, on site only). The change **applies at the next start of eaxScada**.

The retention is stored in `data/genealogy/settings.json`:

```json
{
  "retention": { "gearbox": "15y", "drive-module": "15y", "resin": "10y" }
}
```

A type left out is kept forever. With no retention at all, a purge is refused (`NO_RETENTION`).

**On a high availability pair, set the same retention on both servers.** `data/genealogy/settings.json` (retention, `ack_durability`, the export, pseudonymisation) is per server and **not replicated**: after a failover, the new primary purges with its own file.

## 2. What a purge removes

A purge removes **whole groups of linked units** only: a unit, its components, what it was built into, and theirs. A part is never purged while the product it went into is kept.

A group is purged only when **every** unit in it has a retention, and its newest record is older than the longest retention in the group **by plant time AND by recording time**:

- *plant time* is when the event happened on the line;
- *recording time* is when eaxScada recorded it.

**Example: a legacy import.** In November 2026 you import gearboxes built in 2012 from an older system, with a retention of `10y`. By plant time they are already 14 years old, but by recording time they are new. They are kept until November 2036: the retention counts from the day they were imported.

**Diagram: A legacy import on the two clocks of a purge** (timeline)

Gearboxes built in 2012 are imported in November 2026 with a retention of 10 years. By plant time their retention would have ended in 2022, but by recording time it starts in November 2026. A purge needs the newest record past the retention on both clocks, so the group is kept until November 2036.

**Plant time: when it happened on the line**

- **Gearboxes built**: plant time: 2012 (built)
- **Retention 10y**: by plant time: 2012 to 2022

**Recording time: when eaxScada recorded it**

- **Imported**: recording time: Nov 2026 (imported)
- **Retention 10y**: by recording: to Nov 2036

**The purge**

- **Kept**: until Nov 2036, both past
- **Purge**: of the whole group (not yet; possible). A purge planned before November 2036 leaves the group: its newest record is not older than 10 years by recording time.

The later of the two clocks decides: imported history is kept for its full retention from the day it was recorded.

A purged unit refuses new records. Its serial number can later be created again, as a new unit.

## 3. Plan the purge (dry run)

Choose **Plan a purge (dry run)**. Nothing changes. The plan shows:

- **Units to remove**, **Of which components**, **Records to remove**, **Unit types**;
- the record number the plan was made at, and whether the job was cut to a size limit (the rest is left for a later purge);
- the retention in force, and a grid of the unit types with their unit counts (with **Export CSV**).

Check the counts against what you expect. A type with more units than expected usually means a retention that is too short.

## 4. Sign the purge

Choose **Continue: sign the purge**. The dialog says how many units and records will be removed, and that it cannot be undone in eaxScada: they remain only in the encrypted archive.

1. You are the signer (the signed-in user, shown read only).
2. Enter the **Reason for the purge**, such as "retention of 15 years reached for gearboxes built in 2011", and **Your password**.
3. Choose **Sign and purge**.

eaxScada then, in this order:

1. writes the archive `data/genealogy/archives/genealogy-purge-<time>.eaxgenealogy`, encrypted to the recovery key, reads it back and verifies it;
2. writes the audit record `GENEALOGY_PURGE` (if it cannot, nothing is removed);
3. writes one signed PURGED record that removes the records and keeps a tombstone for each, so the chain stays verifiable.

**Any failure before the PURGED record removes nothing**, and is recorded as `GENEALOGY_PURGE_REFUSED`. Afterwards **Verify** also reports the tombstones and the purges.

A purge is refused:

| Refusal | Why |
|---|---|
| `PURGE_ON_SITE` | You are connected through remote access. A purge is run on site only. |
| `PURGE_ON_PRIMARY` | This server is not the primary of the pair. |
| `NO_RETENTION` | No retention is set (records are kept forever). |
| `NO_RECOVERY_KEY` | No recovery key in the backup settings. |
| busy | Another purge is running. |

## 5. Keep the archives

The **Purge archives** grid on the same tab lists each archive with its size and date. **Download** saves one (Administrator, on site only; each download is recorded as `GENEALOGY_ARCHIVE_DOWNLOAD` with its size and SHA-256). The same list is `GET /api/genealogy/archives`.

**Back up `data/genealogy/archives`** with the rest of `data/genealogy`: after a purge, the archive is the only copy of the removed records. Keep the recovery key's private file as long as you keep the archives.

## 6. Restore and verify an archive

Restoring never touches the live genealogy: it writes into an empty folder, which you then read or verify. The offline commands open genealogy folders for writing, so **eaxScada must be stopped**; while it runs they are refused with exit code 4.

```text
eaxscada.exe genealogy restore --in "D:\archive\genealogy-purge-20361102T071523.523607100Z.eaxgenealogy" --into "D:\restored\genealogy" --recovery-key "E:\keys\eaxscada-recovery-key.txt" --workdir "C:\eaxware\eaxScada"
eaxscada.exe genealogy verify --genealogy "D:\restored\genealogy" --workdir "C:\eaxware\eaxScada"
```

The other offline commands:

| Command | Does |
|---|---|
| `genealogy verify` | Checks the whole chain (exit 0: whole; 3: breaks found) |
| `genealogy archive --from  --to  --out <file>` | Archives the records of those UTC plant days, encrypted to the recovery key, without removing them |
| `genealogy restore --in <file> --into <empty folder> --recovery-key <file>` | Writes an archive's records into an empty folder, never the live one |
| `genealogy rebuild-index` | Rebuilds the trace index and the unit states from the records |
| `genealogy export-hive --out <folder>` | Writes the Parquet export ([Export genealogy for analytics tools](/docs/eaxscada/how-to/export-genealogy-for-analytics-tools/)) |

Common flags: `--workdir`, `--data`, `--genealogy`, `--config`. Exit codes: 0 done, 1 failed, 2 usage, 3 breaks found, 4 the server is running. All flags: [command line](/docs/eaxscada/reference/generated/cli/).

## Verify

- The audit trail holds `GENEALOGY_PURGE` with the counts, the archive name and its seal, signed by you.
- The archive appears in **Purge archives**.
- A purged unit is no longer found by **Search**. Units in groups not yet past their retention, including any group with a linked unit whose type is kept longer, are still found.

## Related

- [Part and lot genealogy](/docs/eaxscada/explanation/genealogy/)
- [Checkpoints, backups and the recovery key](/docs/eaxscada/how-to/checkpoints-fat-sat-and-reverting/)
