Skip to content

Commit 83dc541

Browse files
authored
Merge pull request #1138 from percona/PBM-1544-Add-new-column-showing-the-backup-status
PBM-1544 - Add new column showing the backup "Status" to pbm status output
2 parents 7ee937a + 70bb7e8 commit 83dc541

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmd/pbm/status.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,22 +470,35 @@ func (s storageStat) String() string {
470470
return a.RestoreTS > b.RestoreTS
471471
})
472472

473+
const (
474+
statusSuccess = "success"
475+
statusFailed = "failed"
476+
statusOngoing = "ongoing"
477+
)
478+
479+
var printStatus string
480+
473481
for i := range s.Snapshot {
474482
ss := &s.Snapshot[i]
475483
var status string
476484
switch ss.Status {
477485
case defs.StatusDone:
478486
status = fmt.Sprintf("[restore_to_time: %s]", fmtTS(ss.RestoreTS))
487+
printStatus = statusSuccess
479488
case defs.StatusCancelled:
480489
status = fmt.Sprintf("[!canceled: %s]", fmtTS(ss.RestoreTS))
490+
printStatus = statusFailed
481491
case defs.StatusError:
482492
if errors.Is(ss.Err, errIncompatible) {
483493
status = fmt.Sprintf("[incompatible: %s] [%s]", ss.Err.Error(), fmtTS(ss.RestoreTS))
494+
printStatus = statusSuccess
484495
} else {
485496
status = fmt.Sprintf("[ERROR: %s] [%s]", ss.Err.Error(), fmtTS(ss.RestoreTS))
497+
printStatus = statusFailed
486498
}
487499
default:
488500
status = fmt.Sprintf("[running: %s / %s]", ss.Status, fmtTS(ss.RestoreTS))
501+
printStatus = statusOngoing
489502
}
490503

491504
t := string(ss.Type)
@@ -497,7 +510,7 @@ func (s storageStat) String() string {
497510
if ss.StoreName != "" {
498511
t += ", *"
499512
}
500-
ret += fmt.Sprintf(" %s %s <%s> %s\n", ss.Name, storage.PrettySize(ss.Size), t, status)
513+
ret += fmt.Sprintf(" %s %s <%s> %s %s\n", ss.Name, storage.PrettySize(ss.Size), t, printStatus, status)
501514
}
502515

503516
if len(s.PITR.Ranges) == 0 {

0 commit comments

Comments
 (0)