chore:megafix

This commit is contained in:
2025-11-07 11:28:50 +00:00
parent 64bdd964a2
commit bf9a2b652a
2 changed files with 0 additions and 955 deletions

View File

@ -1,422 +0,0 @@
# Restore Implementation Plan
## Current State
### Existing Infrastructure
- ✅ Database interface with `BuildRestoreCommand()` method
- ✅ RestoreOptions struct defined
- ✅ Placeholder `restore` command in CLI (preview mode only)
- ✅ Archive type detection
- ✅ PostgreSQL and MySQL restore command builders
- ✅ Config with `RestoreDBName` field
### Missing Components
- ❌ Restore engine implementation
- ❌ Progress tracking for restore operations
- ❌ TUI integration for restore
- ❌ Error handling and rollback strategies
- ❌ Pre-restore validation
- ❌ Post-restore verification
## Implementation Plan
### Phase 1: Core Restore Engine (Priority: HIGH)
#### 1.1 Create Restore Engine
**File**: `internal/restore/engine.go`
```go
type Engine struct {
cfg *config.Config
log logger.Logger
db database.Database
progress progress.Indicator
detailedReporter *progress.DetailedReporter
}
// Core methods
- New(cfg, log, db) *Engine
- RestoreSingle(ctx, archivePath, targetDB) error
- RestoreCluster(ctx, archivePath) error
- ValidateArchive(archivePath) error
```
**Features**:
- Archive format detection (dump, sql, tar.gz)
- Decompression handling (gzip, pigz)
- Progress tracking integration
- Error recovery
- Dry-run mode (`--dry-run` flag)
#### 1.2 Archive Format Handlers
**File**: `internal/restore/formats.go`
```go
type ArchiveFormat interface {
Detect(path string) bool
Extract(ctx, path, tempDir) error
GetDatabases() ([]string, error)
}
// Implementations
- PostgreSQLDump // .dump files
- PostgreSQLSQL // .sql files
- MySQLSQL // .sql.gz files
- ClusterArchive // .tar.gz files
```
#### 1.3 Safety Features
**File**: `internal/restore/safety.go`
```go
// Pre-restore checks
- ValidateTargetDatabase()
- CheckDiskSpace()
- VerifyArchiveIntegrity()
- BackupExistingData() // Optional safety backup
// Confirmation system
- RequireConfirmation(archiveInfo, targetDB)
- GenerateRestorePreview()
```
### Phase 2: CLI Integration (Priority: HIGH)
#### 2.1 Update Restore Command
**File**: `cmd/restore.go` (new file, move from placeholder.go)
```bash
# Single database restore
dbbackup restore single backup.dump --target-db myapp_db
# Cluster restore
dbbackup restore cluster cluster_20251105.tar.gz
# With confirmation
dbbackup restore single backup.dump --target-db myapp_db --confirm
# Dry run (preview only)
dbbackup restore single backup.dump --target-db myapp_db --dry-run
# Force overwrite (skip confirmation)
dbbackup restore single backup.dump --target-db myapp_db --force
```
**Flags**:
- `--target-db`: Target database name (for single restore)
- `--confirm`: Enable actual restore (default: preview only)
- `--dry-run`: Show what would be done without executing
- `--force`: Skip confirmation prompts
- `--clean`: Drop existing database before restore
- `--create`: Create database if it doesn't exist
- `--no-owner`: Skip ownership restoration
- `--jobs`: Parallel restore jobs (PostgreSQL only)
#### 2.2 Command Structure
```
dbbackup restore
├── single <archive> --target-db <name>
│ ├── --confirm # Actually execute
│ ├── --dry-run # Preview only
│ ├── --force # Skip prompts
│ ├── --clean # Drop existing
│ ├── --create # Create if missing
│ └── --jobs <n> # Parallel jobs
├── cluster <archive>
│ ├── --confirm
│ ├── --dry-run
│ ├── --exclude <db> # Skip specific DBs
│ └── --include <db> # Only restore specific DBs
└── list <archive> # List archive contents
└── --format json # JSON output
```
### Phase 3: Progress & Monitoring (Priority: MEDIUM)
#### 3.1 Restore Progress Tracking
**File**: `internal/restore/progress.go`
```go
type RestoreProgress struct {
Phase string // "extraction", "restoration", "verification"
Database string
TablesTotal int
TablesRestored int
BytesRestored int64
StartTime time.Time
EstimatedTime time.Duration
}
```
**Output Example**:
```
🔄 Restoring from: backup_20251105.tar.gz
Phase: Extraction
[1/3] Extracting archive...
✅ Archive extracted (56.6 MB)
Phase: Restoration
[2/3] Restoring databases...
[1/13] myapp_db (tables: 45)
├─ users (1.2M rows) ✅
├─ orders (890K rows) ✅
├─ products (12K rows) ✅
✅ Database myapp_db restored (2.5 GB)
Phase: Verification
[3/3] Verifying restore...
✅ All tables verified
✅ Restore completed in 4m 23s
```
### Phase 4: TUI Integration (Priority: MEDIUM)
#### 4.1 TUI Restore Menu
**File**: `internal/tui/restore.go`
```
┌─ Restore Menu ────────────────────────────┐
│ │
│ 1. Restore Single Database │
│ 2. Restore Cluster │
│ 3. List Archive Contents │
│ 4. Back to Main Menu │
│ │
│ Engine: PostgreSQL ◀─────────────▶ │
│ │
└────────────────────────────────────────────┘
```
#### 4.2 Archive Browser
**File**: `internal/tui/archive_browser.go`
```
┌─ Select Archive ──────────────────────────┐
│ │
│ 📦 cluster_20251105_132923.tar.gz │
│ 56.6 MB | 2025-11-05 13:29 │
│ │
│ 📦 db_myapp_20251104_151022.dump │
│ 807 KB | 2025-11-04 15:10 │
│ │
│ ⬅ Back ✓ Select │
└────────────────────────────────────────────┘
```
#### 4.3 Restore Execution Screen
Similar to backup execution but shows:
- Archive being restored
- Target database
- Current phase (extraction/restoration/verification)
- Tables being restored
- Progress indicators
### Phase 5: Advanced Features (Priority: LOW)
#### 5.1 Selective Restore
```bash
# Restore only specific tables
dbbackup restore single backup.dump \
--target-db myapp_db \
--table users \
--table orders \
--confirm
# Restore specific schemas
dbbackup restore single backup.dump \
--target-db myapp_db \
--schema public \
--confirm
```
#### 5.2 Point-in-Time Restore
```bash
# Restore to specific timestamp (requires WAL archives)
dbbackup restore cluster archive.tar.gz \
--target-time "2025-11-05 12:00:00" \
--confirm
```
#### 5.3 Restore with Transformation
```bash
# Rename database during restore
dbbackup restore single prod_backup.dump \
--target-db dev_database \
--confirm
# Restore to different server
dbbackup restore single backup.dump \
--target-db myapp_db \
--host newserver.example.com \
--confirm
```
#### 5.4 Parallel Cluster Restore
```bash
# Restore multiple databases in parallel
dbbackup restore cluster archive.tar.gz \
--jobs 4 \
--confirm
```
## Implementation Order
### Week 1: Core Functionality
1. ✅ Create `internal/restore/engine.go`
2. ✅ Implement `RestoreSingle()` for PostgreSQL
3. ✅ Implement `RestoreSingle()` for MySQL
4. ✅ Add archive format detection
5. ✅ Basic error handling
### Week 2: CLI & Safety
6. ✅ Move restore command to `cmd/restore.go`
7. ✅ Add `--confirm`, `--dry-run`, `--force` flags
8. ✅ Implement safety checks (ValidateArchive, CheckDiskSpace)
9. ✅ Add confirmation prompts
10. ✅ Progress tracking integration
### Week 3: Cluster Restore
11. ✅ Implement `RestoreCluster()` for tar.gz archives
12. ✅ Add extraction handling
13. ✅ Implement global objects restoration (roles, tablespaces)
14. ✅ Add per-database restoration with progress
### Week 4: TUI Integration
15. ✅ Create restore menu in TUI
16. ✅ Add archive browser
17. ✅ Implement restore execution screen
18. ✅ Add real-time progress updates
### Week 5: Testing & Polish
19. ✅ Integration tests
20. ✅ Error scenario testing
21. ✅ Documentation updates
22. ✅ CLI help text refinement
## File Structure
```
dbbackup/
├── cmd/
│ ├── restore.go # NEW: Restore commands
│ └── restore_impl.go # NEW: Restore implementations
├── internal/
│ ├── restore/ # NEW: Restore engine
│ │ ├── engine.go # Core restore engine
│ │ ├── formats.go # Archive format handlers
│ │ ├── safety.go # Pre/post restore checks
│ │ ├── progress.go # Restore progress tracking
│ │ └── verify.go # Post-restore verification
│ ├── tui/
│ │ ├── restore.go # NEW: Restore menu
│ │ ├── archive_browser.go # NEW: Archive selection
│ │ └── restore_exec.go # NEW: Restore execution screen
│ └── database/
│ ├── interface.go # (existing - already has BuildRestoreCommand)
│ ├── postgresql.go # (existing - already has BuildRestoreCommand)
│ └── mysql.go # (existing - already has BuildRestoreCommand)
```
## Key Design Decisions
### 1. Safety-First Approach
- **Default: Preview Mode**: `restore` command shows what would be done
- **Explicit Confirmation**: Require `--confirm` flag for actual execution
- **Dry-Run Option**: `--dry-run` for testing without side effects
- **Pre-restore Validation**: Check archive integrity before starting
### 2. Progress Transparency
- Real-time progress indicators
- Phase-based tracking (extraction → restoration → verification)
- Per-table progress for detailed visibility
- Time estimates and completion ETA
### 3. Error Handling
- Graceful degradation (continue on non-critical errors)
- Detailed error messages with troubleshooting hints
- Transaction-based restoration where possible
- Rollback support (optional safety backup before restore)
### 4. Performance
- Parallel restoration for cluster backups
- Streaming decompression (no temporary files for compressed archives)
- CPU-aware job counts (reuse existing CPU detection)
- Memory-efficient processing (similar to backup streaming)
### 5. Compatibility
- Support all backup formats created by the tool
- Handle legacy backups (if format allows)
- Cross-database restore (with transformations)
- Version compatibility checks
## Testing Strategy
### Unit Tests
- Archive format detection
- Command building (PostgreSQL, MySQL)
- Safety validation logic
- Error handling paths
### Integration Tests
- Single database restore (PostgreSQL, MySQL)
- Cluster restore (PostgreSQL)
- Compressed archive handling
- Large database restoration (memory usage verification)
### Manual Testing Scenarios
1. Restore to same database (overwrite)
2. Restore to different database (rename)
3. Restore to different server
4. Partial restore (selective tables)
5. Cluster restore with exclusions
6. Error scenarios (disk full, connection lost, corrupted archive)
## Documentation Updates
### README.md
```markdown
## Restore Operations
### Single Database
dbbackup restore single backup.dump --target-db myapp_db --confirm
### Cluster Restore
dbbackup restore cluster cluster_20251105.tar.gz --confirm
### Preview Mode (Default)
dbbackup restore single backup.dump --target-db myapp_db
# Shows what would be done without executing
### Flags
- --confirm: Actually execute the restore
- --dry-run: Preview only (explicit)
- --force: Skip confirmation prompts
- --clean: Drop existing database before restore
- --create: Create database if missing
```
### New Documentation Files
- `RESTORE_GUIDE.md`: Comprehensive restore guide
- `RESTORE_BEST_PRACTICES.md`: Safety and performance tips
## Migration Path
Since restore is currently in "preview mode":
1. Keep existing `runRestore()` as reference
2. Implement new restore engine in parallel
3. Add `--legacy` flag to use old preview mode (temporary)
4. Test new implementation thoroughly
5. Remove legacy code after validation
6. Update all documentation
## Success Metrics
- ✅ Single database restore works for PostgreSQL and MySQL
- ✅ Cluster restore works for PostgreSQL
- ✅ All backup formats supported
- ✅ Progress tracking provides clear feedback
- ✅ Safety checks prevent accidental data loss
- ✅ Memory usage remains <1GB for large restores
- TUI integration matches backup experience
- Documentation is comprehensive

View File

@ -1,533 +0,0 @@
# Restore TUI Integration Plan
## Overview
Integrate restore functionality into the interactive TUI menu, following the same architecture patterns as the existing backup features.
---
## Phase 1: Main Menu Integration
### 1.1 Add Restore Menu Items
**File**: `internal/tui/menu.go`
Add new menu choices after backup options:
```go
choices: []string{
"Single Database Backup", // 0
"Sample Database Backup (with ratio)", // 1
"Cluster Backup (all databases)", // 2
"─────────────────────────────", // 3 (separator)
"Restore Single Database", // 4 - NEW
"Restore Cluster", // 5 - NEW
"List & Manage Backups", // 6 - NEW
"─────────────────────────────", // 7 (separator)
"View Active Operations", // 8
"Show Operation History", // 9
"Database Status & Health Check", // 10
"Configuration Settings", // 11
"Clear Operation History", // 12
"Quit", // 13
}
```
### 1.2 Add Menu Handlers
Add cases in `Update()` method:
```go
case 4: // Restore Single Database
return m.handleRestoreSingle()
case 5: // Restore Cluster
return m.handleRestoreCluster()
case 6: // List & Manage Backups
return m.handleBackupList()
```
---
## Phase 2: Archive Browser Component
### 2.1 Create Archive Browser Model
**New File**: `internal/tui/archive_browser.go`
**Purpose**: Browse and select backup archives from the backup directory
**Structure**:
```go
type ArchiveBrowserModel struct {
config *config.Config
logger logger.Logger
parent tea.Model
archives []ArchiveInfo
cursor int
loading bool
err error
title string
mode string // "restore-single", "restore-cluster", "manage"
searchTerm string
filterType string // "all", "postgres", "mysql", "cluster"
}
type ArchiveInfo struct {
Name string
Path string
Format restore.ArchiveFormat
Size int64
Modified time.Time
DatabaseName string
Valid bool
ValidationMsg string
}
```
**Features**:
- List all backup archives in backup directory
- Display archive details (format, size, date, database name)
- Filter by type (PostgreSQL dump, MySQL SQL, cluster)
- Search by filename or database name
- Sort by date (newest first) or name
- Show validation status (valid/corrupted)
- Preview archive contents
- Multi-column display with color coding
**Navigation**:
- ↑/↓: Navigate archives
- Enter: Select archive for restore
- p: Preview archive contents
- f: Toggle filter (all/postgres/mysql/cluster)
- /: Search mode
- Esc: Back to main menu
- d: Delete archive (with confirmation)
- i: Show archive info (detailed)
---
## Phase 3: Restore Preview Component
### 3.1 Create Restore Preview Model
**New File**: `internal/tui/restore_preview.go`
**Purpose**: Show what will be restored and safety checks before execution
**Structure**:
```go
type RestorePreviewModel struct {
config *config.Config
logger logger.Logger
parent tea.Model
archivePath string
archiveInfo ArchiveInfo
targetDB string
options RestoreOptions
safetyChecks []SafetyCheck
warnings []string
executing bool
}
type RestoreOptions struct {
CleanFirst bool
CreateIfMissing bool
TargetDatabase string // if different from original
ForceOverwrite bool
}
type SafetyCheck struct {
Name string
Status string // "pending", "checking", "passed", "failed", "warning"
Message string
Critical bool
}
```
**Safety Checks**:
1. Archive integrity validation
2. Disk space verification (3x archive size)
3. Required tools check (pg_restore/psql/mysql)
4. Target database existence check
5. Data conflict warnings
6. Backup recommendation (backup existing data first)
**Display Sections**:
```
╭─ Restore Preview ────────────────────────────╮
│ │
│ Archive Information: │
│ File: mydb_20241107_120000.dump.gz │
│ Format: PostgreSQL Dump (gzip) │
│ Size: 2.4 GB │
│ Created: 2024-11-07 12:00:00 │
│ Database: mydb │
│ │
│ Target Information: │
│ Database: mydb_restored │
│ Host: localhost:5432 │
│ Clean First: ✓ Yes │
│ Create If Missing: ✓ Yes │
│ │
│ Safety Checks: │
│ ✓ Archive integrity ... PASSED │
│ ✓ Disk space (7.2 GB free) ... PASSED │
│ ✓ Required tools ... PASSED │
│ ⚠ Target database exists ... WARNING │
│ Existing data will be dropped! │
│ │
│ Warnings: │
│ • Restoring will replace all data in │
│ database 'mydb_restored' │
│ • Recommendation: Create backup first │
│ │
╰──────────────────────────────────────────────╯
Options:
[t] Toggle clean-first [c] Toggle create
[n] Change target name [b] Backup first
[Enter] Proceed [Esc] Cancel
```
---
## Phase 4: Restore Execution Component
### 4.1 Create Restore Execution Model
**New File**: `internal/tui/restore_exec.go`
**Purpose**: Execute restore with real-time progress feedback
**Structure**:
```go
type RestoreExecutionModel struct {
config *config.Config
logger logger.Logger
parent tea.Model
archivePath string
targetDB string
cleanFirst bool
createIfMissing bool
restoreType string // "single" or "cluster"
// Progress tracking
status string
phase string // "validating", "decompressing", "restoring", "verifying"
progress int
details []string
startTime time.Time
// Results
done bool
err error
result string
elapsed time.Duration
}
```
**Progress Phases**:
1. **Validating**: Archive validation and safety checks
2. **Decompressing**: If compressed archive (.gz)
3. **Restoring**: Actual database restore operation
4. **Verifying**: Post-restore verification (optional)
**Display**:
```
╭─ Restoring Database ─────────────────────────╮
│ │
│ Phase: Restoring │
│ Status: Importing schema objects... │
│ │
│ ████████████████░░░░░░░░░░░░ 58% │
│ │
│ Details: │
│ • Archive validated successfully │
│ • Decompressing with pigz (4 cores) │
│ • Restored 2,451 tables │
│ • Restored 15,234 sequences │
│ • Importing data... │
│ │
│ Elapsed: 2m 34s │
│ │
╰──────────────────────────────────────────────╯
Press Ctrl+C to cancel (with cleanup)
```
**Pattern**: Follow `backup_exec.go` architecture
- Use tea.Cmd for background execution
- Use tea.Tick for progress updates
- Handle cancellation with cleanup
- Show detailed progress from restore engine
---
## Phase 5: Cluster Restore Flow
### 5.1 Cluster Restore Preview
**Enhancement**: Extend `restore_preview.go` for cluster restores
**Additional Features**:
- List all databases in cluster archive
- Show extraction preview
- Database selection (restore all or subset)
- Sequential restore order
- Estimated time per database
**Display**:
```
╭─ Cluster Restore Preview ────────────────────╮
│ │
│ Archive: cluster_backup_20241107.tar.gz │
│ Type: Full Cluster Backup │
│ Size: 15.8 GB │
│ │
│ Databases to Restore: (Select with Space) │
│ [✓] db_production (2.4 GB) │
│ [✓] db_analytics (8.1 GB) │
│ [✓] db_staging (1.2 GB) │
│ [✓] db_dev (0.8 GB) │
│ [ ] template_db (0.1 GB) │
│ │
│ Total Selected: 4 databases (12.5 GB) │
│ Estimated Time: 45-60 minutes │
│ │
│ Safety: All checks passed ✓ │
│ │
╰──────────────────────────────────────────────╯
[Space] Select [a] Select all [Enter] Proceed
```
---
## Phase 6: Backup Management Component
### 6.1 Backup Management View
**New File**: `internal/tui/backup_manager.go`
**Purpose**: Comprehensive backup archive management
**Features**:
- View all backups with detailed information
- Sort by date, size, name, database
- Filter by type, database, date range
- Show disk usage statistics
- Archive operations:
- Verify integrity
- Delete with confirmation
- Rename/move archives
- Export metadata
- Show detailed info
- Bulk operations (select multiple)
**Display**:
```
╭─ Backup Archive Manager ─────────────────────────────────────╮
│ │
│ Total Archives: 23 | Total Size: 87.4 GB | Free: 142 GB │
│ │
│ Filter: [All Types ▼] Sort: [Date (Newest) ▼] Search: __ │
│ │
│ DATE DATABASE SIZE TYPE STATUS │
│ ────────────────────────────────────────────────────────────│
│ 2024-11-07 12:00 mydb 2.4 GB PG Dump ✓ Valid │
│ 2024-11-07 08:00 cluster 15.8 GB Cluster ✓ Valid │
│ 2024-11-06 23:00 analytics 8.1 GB PG SQL ✓ Valid │
│ 2024-11-06 18:00 testdb 0.5 GB MySQL SQL ✓ Valid │
│ 2024-11-06 12:00 mydb 2.3 GB PG Dump ⚠ Old │
│ │
│ Selected: 0 | [v] Verify [d] Delete [i] Info [r] Restore│
│ │
╰───────────────────────────────────────────────────────────────╯
Navigation: ↑/↓ Select: Space Action: Enter Back: Esc
```
---
## Phase 7: Integration Points
### 7.1 Restore Engine Integration
**File**: `internal/restore/engine.go`
Add TUI-friendly methods:
```go
// NewSilent creates restore engine without progress callbacks
func NewSilent(cfg *config.Config, log logger.Logger, db database.Database) *Engine
// RestoreSingleWithProgress with progress callback
func (e *Engine) RestoreSingleWithProgress(
ctx context.Context,
archivePath, targetDB string,
cleanFirst, createIfMissing bool,
progressCallback func(phase, status string, percent int),
) error
```
### 7.2 Progress Integration
**File**: `internal/progress/progress.go`
Add restore-specific phases:
```go
const (
PhaseRestoreValidation = "Validation"
PhaseRestoreDecompress = "Decompression"
PhaseRestoreImport = "Importing"
PhaseRestoreVerify = "Verification"
)
```
---
## Phase 8: User Experience Enhancements
### 8.1 Keyboard Shortcuts
Global shortcuts in all restore views:
- `?`: Show help overlay
- `Esc`: Back/Cancel
- `Ctrl+C`: Emergency abort
- `Tab`: Switch between panes (if multiple)
### 8.2 Visual Feedback
- Color coding:
- 🟢 Green: Successful operations, valid archives
- 🟡 Yellow: Warnings, old backups
- 🔴 Red: Errors, failed checks, invalid archives
- 🔵 Blue: Info, in-progress operations
- Icons:
- ✓: Success/Valid
- ✗: Failed/Invalid
- ⚠: Warning
- 🔍: Validating
- 💾: Restoring
- 📦: Archive
- 🗄️: Database
### 8.3 Error Handling
- Graceful error recovery
- Clear error messages
- Suggested actions
- Automatic retry on transient failures
- Cleanup on cancellation
---
## Phase 9: Safety Features
### 9.1 Confirmation Dialogs
Use existing `confirmation.go` pattern for:
- Restore with data replacement
- Delete archives
- Cluster restore (all databases)
- Force operations (skip safety checks)
### 9.2 Dry-Run Mode
- Show preview by default
- Require explicit confirmation
- No accidental restores
- Show what would happen
### 9.3 Backup-Before-Restore
Optional feature:
- Offer to backup existing database before restore
- Quick backup with timestamp
- Automatic cleanup of temporary backups
---
## Phase 10: Testing Strategy
### 10.1 Unit Tests
- Archive detection and validation
- Format parsing
- Safety check logic
- Preview generation
### 10.2 Integration Tests
- Complete restore flow
- Cluster restore
- Error scenarios
- Cancellation handling
### 10.3 Manual Testing Scenarios
1. Restore single PostgreSQL dump
2. Restore compressed MySQL SQL
3. Restore full cluster
4. Cancel mid-restore
5. Restore with different target name
6. Restore with clean-first option
7. Handle corrupted archive
8. Handle insufficient disk space
9. Handle missing tools
---
## Implementation Order
### Priority 1 (Core Functionality)
1. ✅ Phase 1: Main menu integration
2. ✅ Phase 2: Archive browser
3. ✅ Phase 3: Restore preview
4. ✅ Phase 4: Restore execution
### Priority 2 (Enhanced Features)
5. Phase 5: Cluster restore flow
6. Phase 6: Backup management
7. Phase 7: Engine integration refinements
### Priority 3 (Polish)
8. Phase 8: UX enhancements
9. Phase 9: Safety features
10. Phase 10: Comprehensive testing
---
## File Structure Summary
```
internal/tui/
├── menu.go # MODIFY: Add restore menu items
├── archive_browser.go # NEW: Browse and select archives
├── restore_preview.go # NEW: Preview restore operation
├── restore_exec.go # NEW: Execute restore with progress
├── backup_manager.go # NEW: Comprehensive backup management
├── confirmation.go # REUSE: For dangerous operations
├── backup_exec.go # REFERENCE: Pattern for execution
└── dbselector.go # REFERENCE: Pattern for selection
internal/restore/
├── engine.go # MODIFY: Add TUI-friendly methods
└── progress.go # NEW: Restore progress tracking
```
---
## Estimated Implementation Time
- **Phase 1-4 (Core)**: 2-3 days
- **Phase 5-7 (Enhanced)**: 2-3 days
- **Phase 8-10 (Polish & Testing)**: 1-2 days
- **Total**: 5-8 days for complete implementation
---
## Success Criteria
✓ User can browse and select backup archives visually
✓ Restore preview shows all relevant information
✓ Safety checks prevent accidental data loss
✓ Progress feedback during restore operation
✓ Error handling with clear messages
✓ Cluster restore supports database selection
✓ Backup management provides archive maintenance
✓ Consistent UX with existing backup features
✓ No console output conflicts (silent operations)
✓ Proper cleanup on cancellation
---
## Notes
- Follow existing TUI patterns from `backup_exec.go` and `dbselector.go`
- Use `backup.NewSilent()` pattern for restore engine
- No `fmt.Println()` or direct console output
- All progress through TUI tea.Msg system
- Reuse existing styles and components where possible
- Maintain consistent keyboard navigation
- Add comprehensive error handling
- Support both PostgreSQL and MySQL restore