Skip to content

Conversation

@leboiko
Copy link
Member

@leboiko leboiko commented Nov 18, 2025

Add a complete set of scripts for backing up, restoring, and managing PostgreSQL/TimescaleDB database with automatic block tracking for blockchain indexing resumption.

New Scripts:

  • backup-db.sh: Creates compressed backups with block tracking
  • restore-db.sh: Restores backups with safety backup and verification
  • verify-db-triggers.sh: Verifies all 26 triggers and database integrity
  • check-latest-block.sh: Analyzes latest block across all tables
  • list-backups.sh: Lists backups with size, date, and block info
  • cleanup-old-backups.sh: Manages backup retention policy

Key Features:

  • Automatic capture of latest ingested block number
  • Block metadata saved with each backup (.block_info files)
  • Trigger-safe backup/restore (all 26 triggers preserved)
  • SHA256 checksums for integrity verification
  • Safety backups before restore operations
  • Detailed verification of triggers, functions, and tables
  • JSON output support for automation
  • Configurable retention policy (default: keep last 7)

Block Tracking:

  • Monitors 10 tables: atom, deposit, redemption, share_price_change, triple, signal, event, fee_transfer, vault, position
  • Compares with stats.last_processed_block_number for validation
  • Provides clear guidance on indexer resumption block

Documentation:

  • BACKUP_README.md: Complete usage guide and workflows
  • BLOCK_TRACKING_README.md: Block tracking implementation details

Tested Features:
✓ Backup creation with block capture (block 1317)
✓ Restore with block verification
✓ All 26 triggers restored and functional
✓ Data integrity maintained (144 accounts, 109 atoms, 65 triples, etc.) ✓ Stats table validation
✓ 1,166 functions and 34 tables restored
✓ JSON output for automation

🤖 Generated with Claude Code

Add a complete set of scripts for backing up, restoring, and managing
PostgreSQL/TimescaleDB database with automatic block tracking for
blockchain indexing resumption.

New Scripts:
- backup-db.sh: Creates compressed backups with block tracking
- restore-db.sh: Restores backups with safety backup and verification
- verify-db-triggers.sh: Verifies all 26 triggers and database integrity
- check-latest-block.sh: Analyzes latest block across all tables
- list-backups.sh: Lists backups with size, date, and block info
- cleanup-old-backups.sh: Manages backup retention policy

Key Features:
- Automatic capture of latest ingested block number
- Block metadata saved with each backup (.block_info files)
- Trigger-safe backup/restore (all 26 triggers preserved)
- SHA256 checksums for integrity verification
- Safety backups before restore operations
- Detailed verification of triggers, functions, and tables
- JSON output support for automation
- Configurable retention policy (default: keep last 7)

Block Tracking:
- Monitors 10 tables: atom, deposit, redemption, share_price_change,
  triple, signal, event, fee_transfer, vault, position
- Compares with stats.last_processed_block_number for validation
- Provides clear guidance on indexer resumption block

Documentation:
- BACKUP_README.md: Complete usage guide and workflows
- BLOCK_TRACKING_README.md: Block tracking implementation details

Tested Features:
✓ Backup creation with block capture (block 1317)
✓ Restore with block verification
✓ All 26 triggers restored and functional
✓ Data integrity maintained (144 accounts, 109 atoms, 65 triples, etc.)
✓ Stats table validation
✓ 1,166 functions and 34 tables restored
✓ JSON output for automation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants