DocsMaintenanceDatabase Corruption Recovery
Master Docs Hub Index
Maintenance • Self-Healing

Database Corruption Recovery & Stream Salvage Engine

If SQLite database corruption occurs due to an ungraceful system shutdown or hardware fault, Nuncio automatically isolates damaged files and salvages valid records into a fresh database.

1. Automatic Recovery Pipeline Steps

  1. Startup Integrity Check (`PRAGMA quick_check(10)`): Executed every time `nunciod` or presentation shells open the database.
  2. Corrupted Backup Isolation (`CorruptedBackupManager`): Damaged `.db`, `.db-wal`, and `.db-shm` files are moved to `~/.nuncio/corrupted_backups/nuncio_corrupted_<timestamp>.db`.
  3. Stream Salvage Extraction (`SqliteRecoveryEngine`): Scans damaged B-trees to salvage valid `accounts`, `filter_rules`, and `filter_conditions`.
  4. Daemon Background Remote Resync: Remote IMAP, JMAP, and Google accounts trigger background sync to rebuild local message caches seamlessly.

2. Manual Database Integrity CLI Commands

# Run manual SQLite integrity check
nuncio store check-integrity

# View isolated corrupted backups directory
ls -l ~/.nuncio/corrupted_backups/