Skip to content

Commit 532fb9f

Browse files
committed
Use postgres user for database backup connections
1 parent 607d890 commit 532fb9f

5 files changed

Lines changed: 7 additions & 2 deletions

File tree

mgradm/cmd/backup/db/disable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func Disable(flags *Flagpole) error {
1717
log.Info().Msg(L("Disabling DB backup"))
1818

1919
wasRunning := false
20-
cnx := shared.NewConnection("podman", podman.DBContainerName, "")
20+
cnx := shared.NewUserConnection("podman", podman.DBContainerName, "", podman.DBRuntimeUser)
2121
if _, err := cnx.GetPodName(); err == nil {
2222
wasRunning = true
2323
if !flags.Force {

mgradm/cmd/backup/db/enable.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func Enable(force bool) error {
2525
return errors.New(L("backup is already configured. Use --force to reconfigure"))
2626
}
2727

28+
// This needs to be root connect because of basebackup script
2829
cnx := shared.NewConnection("podman", podman.DBContainerName, "")
2930
isRunning, _ := cnx.GetPodName()
3031
wasRunning := isRunning != ""

mgradm/cmd/backup/db/rebase.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func Rebase() error {
2020
return fmt.Errorf(L("database backup is not correctly configured: %w"), err)
2121
}
2222

23+
// This needs to be root connect because of basebackup script
2324
cnx := shared.NewConnection("podman", podman.DBContainerName, "")
2425
isRunning, _ := cnx.GetPodName()
2526
wasRunning := isRunning != ""

mgradm/cmd/backup/db/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func Status() error {
5050
// Reports nil if backup is enabled and correctly configured. Otherwise reports an error.
5151
func CheckStatus() error {
5252
log.Debug().Msg("Checking for the database configuration")
53-
cnx := shared.NewConnection("podman", podman.DBContainerName, "")
53+
cnx := shared.NewUserConnection("podman", podman.DBContainerName, "", podman.DBRuntimeUser)
5454
if _, err := cnx.GetPodName(); err == nil {
5555
log.Debug().Msg("Checking for runtime config")
5656
if err := checkStatusSQL(cnx); err != nil {

shared/podman/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ const HubXmlrpcContainerName = "uyuni-hub-xmlrpc"
5050
// DBContainerName represents the database container name.
5151
const DBContainerName = "uyuni-db"
5252

53+
// DBRuntimeUser represents the user under which database is running.
54+
const DBRuntimeUser = "postgres"
55+
5356
// ProxyContainerNames represents all the proxy container names.
5457
var ProxyContainerNames = []string{
5558
"uyuni-proxy-httpd",

0 commit comments

Comments
 (0)