Skip to content

Commit

Permalink
✨ Add flag to force database restores
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Dec 8, 2021
1 parent c3b380f commit 5039d86
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
singleTransaction bool
clean bool
noOwner bool
force bool
)

func init() {
Expand All @@ -44,6 +45,8 @@ func init() {
Command.Flags().BoolVarP(&singleTransaction, "single-transaction", "1", true, "restore as a single transaction")
Command.Flags().BoolVarP(&clean, "clean", "c", true, "clean (drop) database objects before recreating")
Command.Flags().BoolVarP(&noOwner, "no-owner", "O", true, "skip restoration of object ownership in plain-text format")

Command.Flags().BoolVarP(&force, "force", "f", false, "do not prompt before restore")
}

func preRun(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -92,8 +95,10 @@ func run(cmd *cobra.Command, args []string) (err error) {

log.Println("Restoring \"" + args[0] + "\" to \"" + postgresPod.Name + "\"")

if err = cli.Confirm(os.Stdin, false); err != nil {
return err
if !force {
if err = cli.Confirm(os.Stdin, false); err != nil {
return err
}
}

ch := make(chan error)
Expand Down

0 comments on commit 5039d86

Please sign in to comment.