Repository navigation
Backup Restore and PITR
The first release, 0.1.0, ships no automated backup and no point-in-time-recovery (PITR) archive configuration (limitations.md, "Packaging and distribution"). There is no schedule, no backup catalog and no WAL archiving set up by the product. What exists is the set of PostgreSQL tools under a kingres- prefix that you run by hand, one restore-point function in kingres_shard, the export and import of a database and of a table, and documented procedures and limits. This page collects them without promising more. The operator steps are in Runbooks and Operations; the guide text is section 7 of the operator guide.
Planned: phase 22 of the roadmap plans backups made by the product with PostgreSQL native incremental backup, decided on 2026-11-30 (incremental physical backups, a WAL archive, repositories on S3-compatible storage and directories, a cluster restored to a coordinated restore point, one database or one table restored through a scratch restore), and phase 23 plans clones and snapshots. Neither is built; this page describes what can be done today. See Status and Roadmap.
| Item | Where | Notes |
|---|---|---|
| Every shard group's data | each primary's instance directory under /var/lib/kingres
|
A group is the unit of a physical backup; there is no cluster-wide backup command. |
| The system database |
kingres_system (schema kingres_cp) on the map group |
Cluster state. It is also inside the map group's physical backup. |
| The whole node state | /var/lib/kingres |
Stop the service for a cold copy. It includes the CA key and the service credentials, so treat the copy as a secret. |
| Ledger key files and the passphrase |
<ledger-keys-dir> (default <data-dir>/ledger/keys) |
Back up the directory and the passphrase file separately and off the cluster, whenever a key is created or rotated or an anchor credential changes. getLedgerSigning reports backupAdvised until the operator says a backup was made. |
| The record of what was published | <ledger-keys-dir>/published.json |
Mode 0600, no secrets. See "Restoring the system database" below. |
| The CA key and revocation list |
<data-dir>/pki/ca.key and revoked.json on the server that holds the CA |
Back them up off the cluster. The escrow of the key to the servers that host standbys of the map group is off until an administrator switches it on. Without a current copy, after a failover of the map group the new leader raises certificateAuthorityUnavailable until you restore pki/ca.key and pki/revoked.json from the old leader's backup. |
| The key of the data transfer |
<data-dir>/transfer.key (transfer-key-file) |
It seals the staged files of the CSV transfer and of database export; it is part of file-level backups of the data directory. |
| The ledger digests held by auditors | outside the cluster | These are the root of trust; a backup of the database does not replace them. |
-
kingres-pg_dump,kingres-pg_dumpallandkingres-pg_restoreare installed with the package. A dump of a node holds that node's bucket partitions and the reference tables in full, andCREATE EXTENSION IF NOT EXISTS kingres_shard; it holds nothing of the cluster catalog and nothing ofkingres.cluster_secret. It also holds the tableskingres.orphan_*that finished moves left (leave them out with-T 'kingres.orphan_*'). - Restoring a dump of one node.
t/059_restore_node.plruns these cases: (1) a dump restored into an empty database elsewhere gives plain tables, nothing belongs to a cluster; (2) a node that lost its database is put back by creating an empty database with the same name on the server at the node's old address, restoring the dump, then runningSELECT kingres.sync_catalog()on the map group primary, which gives the node the catalog, the secret and its node id; the restored data is as old as the dump; (3) partitions of a node still in the cluster can be repaired from a dump withkingres_shard.enable_routing = offin the restoring session, dumping only the partitions (pg_dump --data-only --disable-triggers -t 'public.d_b*') and emptying the damaged ones first; (4) not supported:add_node()of a node that already holds the tables of the cluster. A dump of a node that took part in a bucket move after the dump was made no longer fits the cluster. -
kingres_timepartpolicies and history are carried bypg_dump(the tables are extension configuration). The restore needs a superuser, and the policies come back with stale OIDs; the next run re-identifies tables by name (timepart_adopt). -
kingres_columnar:pg_dumpwritesCREATE TABLE ... USING columnarand the rows asCOPY; the options of a table live in its metapage, so a restored table takes the settings of the restoring session. -
kingres_ledger:pg_dumpdoes not dump the ledger tables. A restored database has a new, empty ledger with a new chain identity, does not verify as the old one, and inserts into a restored ledger table fail (the entry refers to a table id that is not registered). Use physical backups, standbys orpg_upgrade.
The product has its own export and import, built in phases 14a to 14c (operator guide, sections 12 and 13). They are off by default (cluster setting dataTransfer.enabled), need TLS and kingres_admin, and are a way to copy a database, not a scheduled backup:
-
POST /api/v1/databases/{db}/exportwrites one zip archive (structure, a catalog of what KingresDB adds, one CSV entry per table, a manifest with SHA-256 sums), staged and sealed on the manager leader (transfer-dir) for a limited time. The archive is checked (validateDatabaseArchive) and imported (POST /api/v1/database-imports) as a new database, in this cluster or another. - It carries no roles, grants, functions, triggers, policies or large objects. Plan to make them again by hand.
- A ledger table is carried as data and restarts its chain: the import needs
acknowledgeLedgerRestart: true, and the old blocks, digests, proofs and anchors do not verify against the new database. Keep the exported database and its digests if you must prove the earlier history. - Time-partition policies come back switched off.
- The import needs free space for the expanded archive on every server, fails at its last step when a primary changed during it (do not switch over or drain during an import), and is read as hostile input (only what
pg_dumpwrites is accepted). - Export and import of one table as CSV have no global snapshot (the file of a table spread over several groups is per group), take at most 2 GiB of decompressed CSV in one import and have no batches.
There is no global snapshot in these exports either; see Limitations and Known Issues.
kingres-pg_basebackup -h 127.0.0.1 -U <role with REPLICATION> -D DIR -X stream takes a physical copy (a replication rule in the network access page is needed). kingresd itself uses pg_basebackup -X stream over a certificate-authenticated connection to create and rebuild standbys. pg_basebackup, incremental backup, archive recovery and pg_rewind work with the columnar library preloaded. A base backup taken while writers hold reservations of row numbers restores to a clean state.
kingres.create_restore_point(name) (map group primary, superuser) raises a barrier on every primary, waits until no distributed transaction is between its first PREPARE TRANSACTION and the end of its second phase, calls pg_create_restore_point(name) on every primary, and lowers the barrier. Restoring every server to that name (recovery_target_name = name) gives a state in which no distributed transaction is half committed (tested with three servers restored under a multi-node write load).
What it does not give:
- Standbys. Only primaries get a restore point; a standby is rebuilt from the restored primary.
-
A bucket move in progress. A restore brings the move back as it was;
resume_bucket_moves()(the recovery worker does) undoes or finishes it. - Sequences. Values handed out after that point are handed out again.
- Time. The restore points of the nodes are made at slightly different moments; single-node statements that commit between the first and the last are in one node's restored state and not another's.
- A node with
wal_level = minimalrefuses. - Transactions whose second phase failed or was deferred are in the restored state and are resolved by
kingres.recover_prepared_transactions()after the restore.
After the restore: a restored map primary ends on a new timeline, which the catalog reads as "promoted without it". Run SELECT kingres.promote_node(<the map primary's node id>) on the map primary (it needs the majority of the other groups, which are restored too; repeat until the answer is already).
PITR itself is PostgreSQL's: KingresDB gives the coordinated name, not the WAL archive. Archive settings (archive_command and restore_command) are refused by name in the configuration page of the console because PostgreSQL 18 shows them to every database user.
The ledger cannot prevent a restore and does not try. Restoring a database to an earlier state, or losing the last blocks at an asynchronous failover, gives a chain shorter than what was already published and anchored and, once it accepts new transactions, a different history from that height on: a fork of the same chain_id.
flowchart TD
r["Restore or loss at failover"] --> s["Chain is shorter than published"]
s --> d["Publisher stops the log: diverged, alert ledgerChainDiverged"]
d --> a["Operator acknowledges with a reason"]
a --> e["Task ledger.epoch.start: epoch-closed event, old log closed, new log epoch+1 from block 0"]
e --> v["Verifier: new epoch verifies alone; comparing with old epoch fails and says why"]
- Detection: the publisher finds the head below the published size or a different hash at a published height, stops the log, flags its aggregate member
divergedand raises the critical alertledgerChainDiverged. The database keeps working; nothing is published for that chain until it is acknowledged. - Procedure (console "Acknowledge divergence", REST
acknowledgeLedgerDivergence): the operator states a reason and types the database name; the taskledger.epoch.startpublishes the signed eventepoch-closed, freezes the old log (its tiles stay served for ever), starts epoch e+1 from block 0 of the current chain and clears the alert. Transactions above the common height exist only in the published tiles, anchors and mirrors. - An auditor who holds an anchored head of the old history learns that the history was cut.
kingres-verifyhas--accept-epoch-closed <seq>to turn that failure into a printed finding for the new epoch alone; it never hides the finding. - A physical clone shares the
chain_iduntil the two diverge; publishing under anotheroriginPrefixmakes the logs distinguishable.
- The tiles, checkpoints and anchor records are derived from the chains and from keys the host still has. A restore of
kingres_cpfrom an older backup once made the publisher sign a second root for a published size; since the fix, every holder of the key files keepspublished.jsonwith the highest size and root of every log, and a round compares the database with it. A database that holds less than was published signs nothing and raises the critical alertledgerSignerUnavailablewith subjectpublished-state; it clears itself when the database holds what was published. - Not covered: a restore when every copy of the record is lost or older than the publication, and a restore of both the database and the record to the same older point. Only a mirror or an auditor holding a later checkpoint shows the fork.
-
After a restore of the system database, an operator accepts the loss (ADR 0025, status Accepted). First restart every
kingresdof the cluster: the manager leader raises the term of the ledger when it takes over, and writes of the ledger key set from the old term fail until it has. The critical alertledgerSignerUnavailable(subjectpublished-state) then says what was published, what the database holds, and a confirmation of sixteen hexadecimal digits. Check that the database really was restored and that no newer backup exists. On the host of the manager leader write the confirmation, and on a second line a reason of up to 200 printable ASCII characters, into<ledger-keys-dir>/accept-restore. The leader makes its record what the database holds, one generation higher, keeps the old record aspublished.json.before-restore-<generation>, removes the file and publishes the signed eventrestore-acknowledgedbefore it signs anything else. The logs fork against a mirror that holds the old checkpoints, and the event is the public statement of that. There is no REST operation for this; it needs access to the host of the leader. See Ledger Signing and Publication. - Loss of every signing key file: the chain and published history are not harmed; no further checkpoint can be signed. The console offers "Replace lost key", which marks the key ring
discontinuity: true, and every auditor must replace the trust file with one obtained out of band. - A restored host puts the key directory back from backup before
kingresdstarts; akingresdthat finds no key for anactivekey row raisesledgerSignerUnavailableand signs nothing.
- Automated backup scheduling, a backup catalog, WAL archiving and PITR configuration through the console: none in 0.1.0. The parameters
archive_modeandarchive_commandare refused by the configuration page. - Cluster-wide consistent physical backup other than the restore-point procedure above.
- A backup of the certificate authority key by the product (the escrow to standbys of the map group is optional and is not a backup; keep your own copy).
- Restoring a ledger from a logical dump (there is no supported way to load a ledger with
COPY).
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/guide/limitations.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/guide/operator-guide.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/adr/0025-restore-of-the-system-database-is-accepted-by-an-operator.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/packaging/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_shard/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_ledger/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_timepart/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_columnar/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/control-plane/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/design/ledger-phase7.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/verifier/README.md
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations