Skip to content

Commit

Permalink
use explicit database name with psql
Browse files Browse the repository at this point in the history
  • Loading branch information
majewsky committed Jan 4, 2024
1 parent 1fe7bea commit 5c19926
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions internal/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ func Create(cfg *core.Configuration, reason string) (nowTime time.Time, returned

// determine postgresql server version
cmd := exec.CommandContext(ctx, "psql", //nolint:gosec // input is user supplied and self executed
"-h", cfg.PgHostname, "-U", cfg.PgUsername, //NOTE: PGPASSWORD comes via inherited env variable
"--csv", "--tuples-only", "-c", "SHOW SERVER_VERSION") // output not decoration or padding
cfg.ArgsForPsql("--csv", "--tuples-only", "-c", "SHOW SERVER_VERSION")...) // output not decoration or padding
output, err := cmd.Output()
if err != nil {
return nowTime, fmt.Errorf("could not determine postgresql server version: %w", err)
Expand Down
1 change: 1 addition & 0 deletions internal/core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func NewConfiguration() (*Configuration, error) {
func (cfg Configuration) ArgsForPsql(args ...string) []string {
common := []string{
"-qA", "-h", cfg.PgHostname, "-U", cfg.PgUsername, //NOTE: PGPASSWORD comes via inherited env variable
"-d", "postgres", //ensure that -d does not default to the app username
}
return append(common, args...)
}

0 comments on commit 5c19926

Please sign in to comment.