Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Aug 20, 2023
1 parent e987c66 commit 7626a04
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/internal/database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,23 @@ func (db *Postgres) Upgrade() error {
db.log.Infow("unable to run pg_upgrade on new new datadir, abort upgrade", "output", out, "error", err)
return nil
}
db.log.Infow("pg_ugrade done", "output", string(out))
db.log.Infow("pg_upgrade done", "output", string(out))

// rm -rf /data/postgres
err = os.RemoveAll(db.datadir)
if err != nil {
return fmt.Errorf("unable to remove old datadir %w", err)
}
// mv /data/postgres-new /data/postgres
cmd = exec.Command("cp", "-a", path.Join(newDataDirTemp, "*", db.datadir)) //nolint:gosec
cmd = exec.Command("mv", path.Join(newDataDirTemp, "*"), db.datadir) //nolint:gosec
out, err = cmd.CombinedOutput()
db.log.Infow("pg_ugrade done and new data in place", "output", string(out))
if err != nil {
return fmt.Errorf("unable to copy upgraded datadir to destination, output:%q error %w", string(out), err)
}

return err
db.log.Infow("pg_upgrade done and new data in place", "output", string(out))

return nil
}

func (db *Postgres) getBinaryVersion(pgConfigCmd string) (int, error) {
Expand Down

0 comments on commit 7626a04

Please sign in to comment.