diff --git a/cmd/internal/database/postgres/postgres.go b/cmd/internal/database/postgres/postgres.go index 0d748fe..059546b 100644 --- a/cmd/internal/database/postgres/postgres.go +++ b/cmd/internal/database/postgres/postgres.go @@ -65,7 +65,7 @@ func (db *Postgres) Backup() error { // therefore this happens in the backup task where the database is already available // // implication: one backup has to be taken before an upgrade can be made - err := db.copyPostgresBinaries() + err := db.copyPostgresBinaries(false) if err != nil { return err } diff --git a/cmd/internal/database/postgres/upgrade.go b/cmd/internal/database/postgres/upgrade.go index e5d2b63..0c1714a 100644 --- a/cmd/internal/database/postgres/upgrade.go +++ b/cmd/internal/database/postgres/upgrade.go @@ -43,7 +43,7 @@ func (db *Postgres) Upgrade() error { } // If this is a database directory, save actual postgres binaries for a later major upgrade - err := db.copyPostgresBinaries() + err := db.copyPostgresBinaries(true) if err != nil { return err } @@ -265,12 +265,19 @@ func (db *Postgres) getBinDir(pgConfigCmd string) (string, error) { } // copyPostgresBinaries is needed to save old postgres binaries for a later major upgrade -func (db *Postgres) copyPostgresBinaries() error { +func (db *Postgres) copyPostgresBinaries(override bool) error { binDir, err := db.getBinDir(postgresConfigCmd) if err != nil { return err } + if !override { + if _, err := os.Stat(path.Join(binDir, postgresConfigCmd)); err == nil { + db.log.Info("postgres binaries for later upgrade already in place, not copying") + return nil + } + } + version, err := db.getBinaryVersion(postgresConfigCmd) if err != nil { return err