From 9396c8e6058865b3c72ea8ec1b7b3a00b838f111 Mon Sep 17 00:00:00 2001 From: Alexander Renz Date: Sat, 17 Jan 2026 16:54:20 +0100 Subject: [PATCH] fix: add debug logging for database detection - Always set cmd.Env to preserve PGPASSWORD from environment - Add debug logging for connection parameters and results - Helps diagnose cluster restore database detection issues --- bin/README.md | 4 ++-- internal/restore/safety.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/README.md b/bin/README.md index 837e333..4484703 100644 --- a/bin/README.md +++ b/bin/README.md @@ -4,8 +4,8 @@ This directory contains pre-compiled binaries for the DB Backup Tool across mult ## Build Information - **Version**: 3.42.50 -- **Build Time**: 2026-01-17_15:26:14_UTC -- **Git Commit**: df1ab2f +- **Build Time**: 2026-01-17_15:45:53_UTC +- **Git Commit**: e363e19 ## Recent Updates (v1.1.0) - ✅ Fixed TUI progress display with line-by-line output diff --git a/internal/restore/safety.go b/internal/restore/safety.go index 3269cf3..1102a67 100755 --- a/internal/restore/safety.go +++ b/internal/restore/safety.go @@ -417,10 +417,14 @@ func (s *Safety) listPostgresUserDatabases(ctx context.Context) ([]string, error cmd := exec.CommandContext(ctx, "psql", args...) - // Set password if provided + // Set password - check config first, then environment + env := os.Environ() if s.cfg.Password != "" { - cmd.Env = append(os.Environ(), fmt.Sprintf("PGPASSWORD=%s", s.cfg.Password)) + env = append(env, fmt.Sprintf("PGPASSWORD=%s", s.cfg.Password)) } + cmd.Env = env + + s.log.Debug("Listing PostgreSQL databases", "host", host, "port", s.cfg.Port, "user", s.cfg.User) output, err := cmd.CombinedOutput() if err != nil { @@ -438,6 +442,8 @@ func (s *Safety) listPostgresUserDatabases(ctx context.Context) ([]string, error } } + s.log.Debug("Found user databases", "count", len(databases), "databases", databases, "raw_output", string(output)) + return databases, nil }