> ## Documentation Index
> Fetch the complete documentation index at: https://beads.gascity.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Database Corruption

> Recover from Dolt database corruption

This runbook helps you recover from database corruption in Beads.

## Symptoms

* Error messages during `bd` commands
* "database is locked" errors that persist
* Missing issues that should exist
* Inconsistent database state

## Diagnosis

```bash theme={null}
# Check database integrity
bd doctor

# Check Dolt server health
bd dolt show
```

## Solution

**Step 1:** Stop the Dolt server

```bash theme={null}
bd dolt stop
```

**Step 2:** Back up current state

```bash theme={null}
cp -r .beads .beads.backup
```

**Step 3:** Preview what doctor would fix

```bash theme={null}
bd doctor --dry-run
```

**Step 4:** Rebuild database

```bash theme={null}
bd doctor --fix
```

**Step 5:** Verify recovery

```bash theme={null}
bd doctor
bd list
```

**Step 6:** Restart the Dolt server

```bash theme={null}
dolt sql-server
```

## Prevention

* Let the Dolt server handle synchronization
* Use `bd dolt stop` before system shutdown
* Run `bd doctor` periodically to catch issues early
