Files
dbbackup/main.go
Alexander Renz 9c65821250
All checks were successful
CI/CD / Test (push) Successful in 1m14s
CI/CD / Lint (push) Successful in 1m21s
CI/CD / Build & Release (push) Successful in 3m12s
v3.42.9: Fix all timeout bugs and deadlocks
CRITICAL FIXES:
- Encryption detection false positive (IsBackupEncrypted returned true for ALL files)
- 12 cmd.Wait() deadlocks fixed with channel-based context handling
- TUI timeout bugs: 60s->10min for safety checks, 15s->60s for DB listing
- diagnose.go timeouts: 60s->5min for tar/pg_restore operations
- Panic recovery added to parallel backup/restore goroutines
- Variable shadowing fix in restore/engine.go

These bugs caused pg_dump backups to fail through TUI for months.
2026-01-08 05:56:31 +01:00

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.42.9"
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)
}
}