Skip to content

Commit

Permalink
add pgbackrest check to gatherPgBackRestInfo function
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Hurst committed Sep 11, 2024
1 parent 78e0830 commit db168d3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ func (exec Executor) pgBackRestInfo(output, repoNum string) (string, string, err
return stdout.String(), stderr.String(), err
}

// pgBackRestCheck defines a pgBackRest check command
// Force log-level-console=detail to override if set elsewhere
func (exec Executor) pgBackRestCheck() (string, string, error) {
var stdout, stderr bytes.Buffer
command := "pgbackrest check --log-level-console=detail"
err := exec(nil, &stdout, &stderr, "bash", "-ceu", "--", command)

return stdout.String(), stderr.String(), err
}

// postgresqlListLogFiles returns the full path of numLogs log files.
func (exec Executor) listPGLogFiles(numLogs int) (string, string, error) {
var stdout, stderr bytes.Buffer
Expand Down
15 changes: 15 additions & 0 deletions internal/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,21 @@ func gatherPgBackRestInfo(ctx context.Context,
buf.Write([]byte(stderr))
}

buf.Write([]byte("pgbackrest check\n"))
stdout, stderr, err = Executor(exec).pgBackRestCheck()
if err != nil {
if apierrors.IsForbidden(err) {
writeInfo(cmd, err.Error())
return nil
}
return err
}

buf.Write([]byte(stdout))
if stderr != "" {
buf.Write([]byte(stderr))
}

path := clusterName + "/pgbackrest-info"
return writeTar(tw, buf.Bytes(), path, cmd)
}
Expand Down

0 comments on commit db168d3

Please sign in to comment.