Skip to content

Commit

Permalink
feat(server): add --enable-backup flag to "create" command (#568)
Browse files Browse the repository at this point in the history
As requested in #488
  • Loading branch information
phm07 authored Oct 19, 2023
1 parent e313e69 commit 15adee0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/cmd/server/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ var CreateCmd = base.Cmd{
cmd.Flags().StringSlice("enable-protection", []string{}, "Enable protection (delete, rebuild) (default: none)")
cmd.RegisterFlagCompletionFunc("enable-protection", cmpl.SuggestCandidates("delete", "rebuild"))

cmd.Flags().Bool("enable-backup", false, "Enable automatic backups")

return cmd
},

Expand Down Expand Up @@ -112,6 +114,20 @@ var CreateCmd = base.Cmd{
return err
}

enableBackup, _ := cmd.Flags().GetBool("enable-backup")
if enableBackup {
action, _, err := client.Server().EnableBackup(ctx, server, "")
if err != nil {
return err
}

if err := actionWaiter.ActionProgress(ctx, action); err != nil {
return err
}

fmt.Printf("Backups enabled for server %d\n", server.ID)
}

if !server.PublicNet.IPv4.IsUnspecified() {
fmt.Printf("IPv4: %s\n", server.PublicNet.IPv4.IP.String())
}
Expand Down

0 comments on commit 15adee0

Please sign in to comment.