PATINA docs

Back up and restore

Almost nothing in a PATINA deployment is precious, because almost all of it is derived from the blockchain. Knowing which part is which saves you from protecting the wrong thing.

What you will know after this page
  • Which four items in a deployment are precious, and why the index itself is not one of them.
  • What metadata has to travel with a snapshot for anyone to trust it after a restore.
  • The restore order: check the metadata, restore into a store that is not serving, verify the root at the recorded height, catch up, cross check, then take traffic.
  • The cheapest recovery path for six situations, including the one where restoring destroys the evidence.
  • Why no backup can restore an artifact, undo a spend, or bring back a relic.

Precious or derived

Eight things live in a deployment. Only the first four cannot be recovered from the chain, and none of them is large enough to be a problem. If you protect nothing else, protect those.

What actually needs a backup.
ItemClassIf you lose it
Deployment recordPreciousYou do not know which window heights you were indexing. Keep it in version control.
Specification and spec_sha256PreciousYou cannot prove what rules you ran. Keep it in version control.
ConfigurationPreciousRebuildable by hand, slowly and with mistakes. Keep it in version control.
Verification logPreciousYou lose the last known good height, which is what makes an investigation finite.
The index itselfDerivedNothing, except the time to rebuild it
Cached API responsesDerivedNothing
Metrics historyUseful, not preciousYou lose trend context for alerts
Bitcoin node dataDerived, expensiveNothing, except a long resync
Backing up the index is a speed decision

The index contains no unique information. A snapshot exists so that recovery takes minutes instead of a rebuild, and for no other reason. If a snapshot is ever inconvenient or of doubtful integrity, throw it away and reindex. Rebuilding is always correct.

Snapshot procedure

  1. Record the height and the root

    Note indexed_height and the state root at that height. A snapshot without them cannot be verified after restore.

  2. Take a consistent copy

    Stop writes, or use whatever consistent snapshot mechanism your storage engine provides. A copy taken while blocks are being applied is not a snapshot, it is a mixture.

  3. Store the metadata with it

    Network, spec_sha256, parser_version, indexer_version, indexed_height, the state root, and the timestamp.

  4. Checksum the archive

    So a corrupt restore is detected before it is served rather than after.

Restore procedure

  1. Check the metadata first

    Same network, same spec_sha256. A snapshot from a different specification must not be restored, because it was produced by different rules.

  2. Restore into a store that is not serving

    Never restore over a live index.

  3. Verify the root at the recorded height

    It must equal the root recorded when the snapshot was taken. If it does not, the snapshot is corrupt. Discard it and reindex.

  4. Catch up

    Let it index forward to the current tip with /ready failing throughout.

  5. Cross check before serving

    Compare the state root against a second implementation at a common height. Only then take traffic.

Recovery paths, by situation

Find your row first, then act. One row tells you not to restore anything at all, because a restore would erase the evidence you need to explain what happened.

Pick the cheapest path that ends in a verified state.
SituationPath
Process crashed, storage intactRestart. Confirm it resumes from its last height.
Unclean shutdown, storage integrity unknownRestore a snapshot, or reindex. Do not guess.
Storage lostRestore a snapshot and catch up, or reindex.
Snapshot fails root verificationReindex. Report the snapshot as bad so nobody else restores it.
State root disagrees with another implementationDo not restore anything. Investigate first. Restoring hides the evidence.
Whole host lostNew host, node from scratch or from its own snapshot, then index restore or rebuild.

Drill it

A restore procedure that has never been run is a hypothesis. Run it on a schedule:

  1. Restore the most recent snapshot onto a clean host.
  2. Verify the root at the recorded height.
  3. Catch up to tip.
  4. Compare against the live indexer at a common height.
  5. Write down how long the whole thing took. That number is your real recovery time, and it is the one to quote when someone asks.

What a backup cannot do

  • It cannot restore an artifact. Artifacts live on the blockchain, not in your database.
  • It cannot undo a spend, restore depth, or bring back a relic.
  • It cannot recover anything for a user, because the indexer holds nothing that belongs to them.

That is the point of the architecture. The worst operational disaster in this stack costs time, not anyone's property. The public site puts the same case to holders, including what survives if this operation stops entirely, on every way this can let you down.