Engineer reviewing real-time oracle price feeds on ultrawide monitor, data visualizations on second screen, clean desk setup in bright apartment.
Protocols

Database Backup, Restore, and Disaster Recovery

A comprehensive operational guide on PostgreSQL backup strategies, point-in-time recovery procedures, and disaster recovery planning for indexer databases containing full indexed state. Critical for business continuity.
introduction
INDEXER STATE CONTINUITY

Introduction

A technical overview of PostgreSQL backup, point-in-time recovery, and disaster recovery strategies for The Graph indexer databases.

For indexers on The Graph, the PostgreSQL database is not merely a cache; it is the primary state store containing the fully indexed history of every allocated subgraph. Losing this database means losing weeks or months of indexing work, resulting in substantial query fee and indexing reward losses during the rebuild period. Database backup, restore, and disaster recovery (DR) planning is therefore a critical operational requirement for business continuity, not an optional administrative task.

A robust strategy moves beyond simple pg_dump logical backups to continuous physical backups using Write-Ahead Log (WAL) archiving. This enables point-in-time recovery (PITR), allowing an indexer to restore the database to the exact moment before a failure, minimizing data loss to seconds rather than hours. The operational complexity arises from managing the interplay between graph-node's block ingestion, the WAL archiving process, and the base backup schedule, all while maintaining query performance and avoiding disk I/O saturation.

Disaster recovery planning must account for the unique failure modes of an indexer: database corruption from unexpected shutdowns, cascading failures from a bad subgraph manifest triggering infinite indexing loops, or cloud provider zone outages. A validated DR runbook should define Recovery Time Objectives (RTO) and Recovery Point Objectives (RPO) specific to the cost of indexing downtime, and include procedures for failing over to a standby database or restoring from an off-site backup archive. Chainscore Labs can design and validate these backup and recovery procedures, ensuring indexer operators can restore service within acceptable business parameters.

DATABASE RESILIENCE FOR INDEXERS

Quick Facts

Operational facts for indexers evaluating backup, restore, and disaster recovery procedures for PostgreSQL databases containing full indexed state.

AreaWhat changesWho is affectedAction

Backup Scope

Full indexed subgraph state, chain data, and allocation metadata must be captured; partial backups lead to unrecoverable corruption

Indexers, Gateway Operators

Validate backup completeness by performing a test restore and verifying subgraph query integrity

Point-in-Time Recovery

WAL archiving and base backups enable recovery to a specific transaction, minimizing data loss from logical corruption or operator error

Indexers

Configure continuous WAL archiving and regularly test PITR to a known-good state

Recovery Time Objective

Restore duration depends on database size, backup format, and infrastructure throughput; slow recovery extends indexing downtime and query unavailability

Indexers, dApp Teams

Benchmark restore times for full database and measure against acceptable downtime thresholds

Backup Storage and Retention

Off-site, immutable backup storage protects against infrastructure failure, ransomware, and accidental deletion

Indexers

Implement automated backup replication to a separate provider and enforce retention policies aligned with slashing unbonding periods

Disaster Recovery Testing

Untested backups are a primary cause of extended outages; procedural gaps only surface during actual incidents

Indexers, DevOps Teams

Schedule regular disaster recovery drills including full stack restoration and query validation

Graph Node State Consistency

Restoring a database without matching graph-node version and configuration can cause startup failures or silent data corruption

Indexers

Document and version-pin the exact graph-node release, configuration, and environment variables alongside each backup

Chain Head Synchronization

Post-restore, graph-node must catch up to the chain tip; excessive lag can trigger allocation penalties or missed rewards

Indexers

Monitor sync lag after restore and delay re-allocation until the node is fully synchronized

Query Gateway Failover

During database recovery, queries must be routed to healthy indexers or served from cached data to prevent dApp disruption

Gateway Operators, dApp Teams

Implement gateway-level circuit breakers and stale-data fallback policies for indexer outage scenarios

technical-context
INDEXER DATA RESILIENCE

Backup Strategy and Technical Mechanism

The technical architecture and operational logic for backing up and restoring the massive PostgreSQL databases that underpin The Graph's indexing layer.

For indexers on The Graph, the PostgreSQL database is the single source of truth, containing the fully materialized state of every indexed subgraph. A loss of this database is a catastrophic event, requiring a complete re-synchronization from genesis that can take weeks for high-throughput chains like Ethereum mainnet. The backup strategy is therefore not a simple administrative task but a core component of an indexer's business continuity plan, directly protecting against slashing risks, query fee revenue loss, and reputational damage from extended downtime.

The standard technical mechanism relies on PostgreSQL's continuous archiving and point-in-time recovery (PITR) features. This involves running the database in WAL (Write-Ahead Log) archival mode, where a base backup is taken periodically using pg_basebackup, and all subsequent transaction logs are continuously streamed to a secure, off-server location. In a disaster scenario, an operator restores the base backup and replays the archived WAL segments to bring the database to a consistent state just before the failure, minimizing data loss to the last archived transaction. This process must be rigorously tested, as an untested backup is a proven liability.

The operational impact extends to the graph-node software itself, which must be gracefully shut down or paused during backup operations to ensure filesystem-level consistency, particularly when using volume snapshots as an alternative to logical backups. A recovery procedure must also account for the tight coupling between the database state and the specific graph-node version, as schema migrations between releases can render a restored database incompatible without a corresponding downgrade or upgrade path. Chainscore Labs can design and validate these end-to-end recovery runbooks, ensuring that an indexer's disaster recovery plan is not just documented but operationally sound under real failure conditions.

DISASTER RECOVERY IMPACT

Affected Actors

Indexer Impact

Indexers are the primary affected actor. A database failure without a validated recovery procedure means permanent loss of indexed state, leading to slashing risks, allocation termination, and query fee revenue loss.

Critical actions:

  • Validate that PostgreSQL backups are consistent and include WAL archives for point-in-time recovery.
  • Test restore procedures in a staging environment before production deployment.
  • Ensure backup storage is geographically separate from the primary node.
  • Document recovery time objectives (RTO) and recovery point objectives (RPO) for each subgraph.

Chainscore can design and validate backup and recovery procedures tailored to your indexer stack.

implementation-impact
DATABASE RESILIENCE FOR INDEXERS

Implementation and Operational Impact

A comprehensive backup and disaster recovery strategy is the single most critical operational control for indexers. Loss of the primary database means losing all indexed state, requiring a full re-sync that can take weeks and forfeit query fee revenue.

01

Point-in-Time Recovery Architecture

Implement continuous WAL archiving to enable point-in-time recovery (PITR) for PostgreSQL databases. This allows restoration to any moment before a failure, minimizing data loss to seconds rather than hours. Indexers must configure archive_command to ship WAL segments to a separate, durable storage location. Without PITR, a database corruption event forces a full re-index from genesis, which for high-volume subgraphs can mean weeks of downtime and lost query fees. Chainscore can validate your WAL archiving pipeline and recovery procedures.

02

Backup Strategy and Validation Testing

A backup that has never been restored is not a backup. Indexers must schedule regular pg_basebackup operations and, critically, perform automated restore tests in an isolated environment. This validates backup integrity, measures recovery time objectives (RTO), and ensures the operational team is practiced in the procedure. Common failure points include missing WAL segments, incorrect permissions, or insufficient disk space on the restore target. Chainscore can design a full backup validation framework and runbook tailored to your indexer stack.

03

Disaster Recovery Site and Failover Planning

Maintain a geographically separate disaster recovery (DR) environment with a warm standby database using streaming replication. In the event of a primary site failure, operators can promote the standby and redirect graph-node instances. The DR plan must account for DNS cutover for query endpoints, reconfiguration of indexer-agent to point to the new database, and state channel continuity to avoid payment disputes. Without a documented and tested failover procedure, a data center outage becomes a prolonged service disruption. Chainscore can review your DR architecture and failover automation.

04

Monitoring and Alerting for Backup Health

Implement proactive monitoring on backup processes, not just database uptime. Critical metrics include WAL archive lag, last successful base backup timestamp, replication slot status, and available storage capacity on backup targets. Silent backup failures are a leading cause of unrecoverable data loss. Alert thresholds should trigger before storage exhaustion or replication lag exceeds the acceptable recovery point objective (RPO). Chainscore can build Prometheus alerting rules and Grafana dashboards specifically for indexer database backup health.

05

Operational Runbook for Database Incidents

A clear, tested runbook is essential for responding to database corruption, accidental data deletion, or hardware failure. The runbook must define decision trees: when to attempt PITR versus failing over to a standby, who has authority to initiate recovery, and how to communicate status to delegators and gateway users. Post-recovery steps should include verifying subgraph indexing has resumed correctly and that query responses match on-chain state. Chainscore can help develop and tabletop-test incident response procedures specific to indexer database failures.

06

Storage Cost and Retention Policy Design

Indexer databases storing full indexed state can grow to multiple terabytes. Backup retention policies must balance recovery needs against storage costs. Define separate retention periods for base backups and WAL archives based on the maximum acceptable recovery window. Consider tiered storage with object storage for older backups. A common mistake is retaining only the latest base backup, which is useless if corruption existed before it was taken. Chainscore can model storage costs and design retention policies aligned with your recovery objectives.

DATABASE FAILURE AND RECOVERY RISKS

Risk Matrix

Operational risks associated with indexer PostgreSQL database failures and the effectiveness of backup, restore, and disaster recovery procedures.

RiskFailure modeSeverityMitigation

Incomplete backups

Logical backups (pg_dump) omit large objects or fail silently on corrupted blocks, leading to unrestorable state.

Critical

Implement physical backups (pg_basebackup) with WAL archiving and regularly test full restore procedures.

Excessive recovery time

Restoring a multi-terabyte database from object storage exceeds the acceptable downtime window, causing extended query service disruption.

High

Maintain a hot standby replica for rapid failover and practice incremental recovery drills to meet RTO targets.

WAL archive failure

A misconfigured or full WAL archive destination prevents point-in-time recovery, leaving only the last base backup available.

High

Monitor WAL archive lag and disk usage with Prometheus alerts; validate archive integrity with pg_waldump checks.

Replica divergence

A streaming replica falls behind or diverges due to network partition, making it useless for failover and causing data loss on promotion.

High

Monitor replication lag and use synchronous replication for critical databases; automate fencing of stale replicas.

Operator key loss

The indexer operator wallet key is lost or corrupted on the database server, preventing on-chain allocation management after a restore.

Critical

Store operator keys in a secrets manager or HSM, never solely on the database host; test key recovery as part of DR drills.

Backup corruption

Bit rot or storage-level corruption silently damages backup files, discovered only during a restore attempt after a primary failure.

Critical

Compute and verify checksums on all backup files; periodically restore to a sandbox environment and validate indexing resumes.

Configuration drift

Restored database is incompatible with the current graph-node version due to missed migration steps, causing startup failure.

Medium

Version-control graph-node configurations and database migration scripts; include a configuration audit step in the recovery runbook.

DATABASE BACKUP, RESTORE, AND DISASTER RECOVERY

Operator Readiness Checklist

A checklist for indexer operators to validate their PostgreSQL backup and disaster recovery posture. Each item identifies what to verify, why it matters for indexing continuity, and the signal that confirms readiness.

What to check: Confirm that your backup strategy captures the full PostgreSQL data directory, including all subgraph-deployment schemas and Write-Ahead Log (WAL) archives. Verify that backups run at a frequency aligned with your Recovery Point Objective (RPO).

Why it matters: An incomplete backup missing WAL segments or specific schemas can render the entire recovery useless. Indexers risk losing days or weeks of indexing work, requiring full re-synchronization from genesis.

Readiness signal: A recent, automated test restore succeeded without schema errors or missing data blocks. Backup logs show consistent success with no skipped WAL segments.

Chains We Build On

Looking to build on a specific blockchain?

We build smart contracts, DeFi applications, wallets, tokenization platforms, and blockchain infrastructure across the major ecosystems teams choose today. That includes Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Solana, Sui, Aptos, Hedera, Stellar, and NEAR, with support for additional EVM and non-EVM networks based on your product requirements.

EVM ecosystems

  • Ethereum logo
    Ethereum
  • Arbitrum logo
    Arbitrum
  • Optimism logo
    Optimism
  • Polygon logo
    Polygon
  • Avalanche logo
    Avalanche
  • Cronos logo
    Cronos

Non-EVM ecosystems

  • Solana logo
    Solana
  • Sui logo
    Sui
  • Aptos logo
    Aptos
  • Hedera logo
    Hedera
  • Stellar logo
    Stellar
  • NEAR logo
    NEAR

Additional ecosystems

  • Polkadot logo
    Polkadot
  • Cosmos logo
    Cosmos
  • TON logo
    TON
  • Cardano logo
    Cardano
  • Algorand logo
    Algorand
  • Tempo logo
    Tempo

Also available for Base, appchains, custom EVM networks, and cross-chain product architecture.

DATABASE BACKUP AND RECOVERY FAQ

Frequently Asked Questions

Answers to common operational questions about protecting PostgreSQL databases that store full indexed state for The Graph indexers. Covers backup strategies, recovery procedures, and business continuity planning.

Indexers should implement a layered backup strategy combining physical and logical backups:

  • Continuous WAL archiving: Enable PostgreSQL WAL archiving to a separate storage location. This enables point-in-time recovery (PITR) and is essential for minimizing data loss.
  • Daily physical backups: Use pg_basebackup or filesystem snapshots to capture full database state. Physical backups are faster to restore than logical dumps for large databases.
  • Periodic logical dumps: Schedule pg_dump exports of critical schemas as a fallback. Logical backups are portable across PostgreSQL versions but slower to restore.
  • Off-site storage: Replicate backups to a different geographic region or cloud provider. Local backups do not protect against hardware failure, fire, or data center outages.

Chainscore can design and validate backup procedures tailored to your indexer's database size, recovery time objectives, and infrastructure.

Trusted by Industry Leaders

Delivering blockchain solutions for 5+ years.

We have partnered with 50+ leading DeFi protocols, NFT ecosystems, and fintech innovators to build secure, scalable, and capital-efficient blockchain products.

Selected Partners & Clients

ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
I've been working with Chainscore Labs for last 3+ years, they've consistently delivered with strong ownership across multiple projects. The team is reliable and detail-oriented.
L
Lee Erswell
CEO, Telos Foundation
how to get started

How to get started?

If you're looking for blockchain integration, ChainScore Labs has 5+ years of experience helping teams build and integrate exchanges, wallets, smart contracts, tokenization solutions, and protocol-connected products, we can help you choose the right path, integrate securely, and get to production faster. Our team consists of experienced blockchain developers and architects who can help you with your blockchain integration needs.

01

Exploration & Strategy

Define your product goals and choose the right blockchain architecture for your use case.

02

Architecture & Design

Design the smart contracts, tokenomics, and security parameters of your system.

03

Development & Integration

Build and integrate with wallets, oracles, and front-end dApps for a seamless experience.

04

Security & Launch

Comprehensive audits followed by a risk-managed mainnet deployment to protect your users.

Start a build

Need a blockchain engineering team?

Send the project context and we will respond with next steps, scope questions, and a practical path to delivery.