Features: - restore diagnose command for backup file analysis - Deep COPY block verification for truncated dump detection - PGDMP signature and gzip integrity validation - Detailed error reports with --save-debug-log flag - Ring buffer stderr capture (prevents OOM on 2M+ errors) - Error classification with actionable recommendations TUI Enhancements: - Automatic dump validity safety check before restore - Press 'd' in archive browser to diagnose backups - Press 'd' in restore preview for debug log toggle - Debug logs saved to /tmp on failure when enabled Documentation: - Updated README with diagnose command and examples - Updated CHANGELOG with full feature list - Updated restore preview screenshots
67 lines
1.4 KiB
Go
Executable File
67 lines
1.4 KiB
Go
Executable File
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log/slog"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"dbbackup/cmd"
|
|
"dbbackup/internal/config"
|
|
"dbbackup/internal/logger"
|
|
"dbbackup/internal/metrics"
|
|
)
|
|
|
|
// Build information (set by ldflags)
|
|
var (
|
|
version = "3.40.0"
|
|
buildTime = "unknown"
|
|
gitCommit = "unknown"
|
|
)
|
|
|
|
func main() {
|
|
// Create context that cancels on interrupt
|
|
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
defer cancel()
|
|
|
|
// Initialize configuration
|
|
cfg := config.New()
|
|
|
|
// Set version information
|
|
cfg.Version = version
|
|
cfg.BuildTime = buildTime
|
|
cfg.GitCommit = gitCommit
|
|
|
|
// Optimize CPU settings if auto-detect is enabled
|
|
if cfg.AutoDetectCores {
|
|
if err := cfg.OptimizeForCPU(); err != nil {
|
|
slog.Warn("CPU optimization failed", "error", err)
|
|
}
|
|
}
|
|
|
|
// Initialize logger
|
|
log := logger.New(cfg.LogLevel, cfg.LogFormat)
|
|
|
|
// Initialize global metrics
|
|
metrics.InitGlobalMetrics(log)
|
|
|
|
// Show session summary on exit
|
|
defer func() {
|
|
if metrics.GlobalMetrics != nil {
|
|
avgs := metrics.GlobalMetrics.GetAverages()
|
|
if ops, ok := avgs["total_operations"].(int); ok && ops > 0 {
|
|
fmt.Printf("\n📊 Session Summary: %d operations, %.1f%% success rate\n",
|
|
ops, avgs["success_rate"])
|
|
}
|
|
}
|
|
}()
|
|
|
|
// Execute command
|
|
if err := cmd.Execute(ctx, cfg, log); err != nil {
|
|
log.Error("Application failed", "error", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|