Skip to content

Commit 78e0830

Browse files
philrhurstPhilip Hurst
andauthored
More support export logs (#102)
* Get Postgres logs from Primary and Replicas * Get Postgres configuration files from PGDATA directory * Get pgBackRest logs from DB host(s) and Repo hosts * Store files in `pods/pod-name` directory * Rename PGO log from `cli` to `cli.log` --------- Co-authored-by: Philip Hurst <[email protected]>
1 parent 9782c9b commit 78e0830

File tree

7 files changed

+404
-43
lines changed

7 files changed

+404
-43
lines changed

internal/cmd/exec.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,39 @@ func (exec Executor) listPGLogFiles(numLogs int) (string, string, error) {
4949
return stdout.String(), stderr.String(), err
5050
}
5151

52+
// listPGConfFiles returns the full path of Postgres conf files.
53+
// These are the *.conf stored on the Postgres instance
54+
func (exec Executor) listPGConfFiles() (string, string, error) {
55+
var stdout, stderr bytes.Buffer
56+
57+
command := "ls -1dt pgdata/pg[0-9][0-9]/*.conf"
58+
err := exec(nil, &stdout, &stderr, "bash", "-ceu", "--", command)
59+
60+
return stdout.String(), stderr.String(), err
61+
}
62+
63+
// listBackrestLogFiles returns the full path of pgBackRest log files.
64+
// These are the pgBackRest logs stored on the Postgres instance
65+
func (exec Executor) listBackrestLogFiles() (string, string, error) {
66+
var stdout, stderr bytes.Buffer
67+
68+
command := "ls -1dt pgdata/pgbackrest/log/*"
69+
err := exec(nil, &stdout, &stderr, "bash", "-ceu", "--", command)
70+
71+
return stdout.String(), stderr.String(), err
72+
}
73+
74+
// listBackrestRepoHostLogFiles returns the full path of pgBackRest log files.
75+
// These are the pgBackRest logs stored on the repo host
76+
func (exec Executor) listBackrestRepoHostLogFiles() (string, string, error) {
77+
var stdout, stderr bytes.Buffer
78+
79+
command := "ls -1dt pgbackrest/*/log/*"
80+
err := exec(nil, &stdout, &stderr, "bash", "-ceu", "--", command)
81+
82+
return stdout.String(), stderr.String(), err
83+
}
84+
5285
// catFile takes the full path of a file and returns the contents
5386
// of that file
5487
func (exec Executor) catFile(filePath string) (string, string, error) {

0 commit comments

Comments
 (0)