Skip to content

Commit d23b774

Browse files
Anthony Landrethtony-landreth
authored andcommitted
Add suggestions to restore and backup for conflict
Issue: PGO-646
1 parent 80900a2 commit d23b774

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

internal/cmd/backup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package cmd
1616

1717
import (
1818
"context"
19+
"strings"
1920
"time"
2021

2122
"github.com/spf13/cobra"
@@ -128,6 +129,9 @@ postgresclusters/hippo backup initiated`)
128129
)
129130

130131
if err != nil {
132+
if strings.Contains(err.Error(), "conflict") {
133+
cmd.Printf("SUGGESTION: The --force-conflicts flag may help in performing this operation.")
134+
}
131135
cmd.Printf("\nError requesting update: %s\n", err)
132136
return err
133137
}

internal/cmd/restore.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ func newRestoreCommand(config *internal.Config) *cobra.Command {
3333
cmd := &cobra.Command{
3434
Use: "restore CLUSTER_NAME",
3535
Short: "Restore cluster",
36-
Long: `Restore the data of a PostgreSQL cluster from a backup
36+
Long: `Restore the data of a PostgreSQL cluster from a backup either by
37+
using the current "spec.backups.pgbackrest.restore" settings on the PostgreSQL
38+
cluster or by using flags to write your settings. Overwriting those settings
39+
may require the --force-conflicts flags.
3740
3841
### RBAC Requirements
3942
Resources Verbs
@@ -190,6 +193,9 @@ func (config pgBackRestRestore) Run(ctx context.Context) error {
190193
config.PostgresCluster, types.ApplyPatchType, patch,
191194
config.Patch.PatchOptions(patchOptions))
192195
if err != nil {
196+
if strings.Contains(err.Error(), "conflict") {
197+
fmt.Fprintf(config.Out, "SUGGESTION: The --force-conflicts flag may help in performing this operation.\n")
198+
}
193199
return err
194200
}
195201

0 commit comments

Comments
 (0)