Skip to content

Commit

Permalink
*: fix parameter checking
Browse files Browse the repository at this point in the history
Signed-off-by: BornChanger <dawn_catcher@126.com>
  • Loading branch information
BornChanger committed Oct 19, 2023
1 parent 0f44807 commit ee0b230
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/backup-manager/app/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func NewRestoreCommand() *cobra.Command {
cmd.Flags().StringVar(&ro.PitrRestoredTs, "pitrRestoredTs", "0", "The pitr restored ts")
cmd.Flags().BoolVar(&ro.Prepare, "prepare", false, "Whether to prepare for restore")
cmd.Flags().StringVar(&ro.TargetAZ, "target-az", "", "For volume-snapshot restore, which az the volume snapshots restore to")
cmd.Flags().BoolVar(&ro.UseFSR, "use-fsr", false, "EBS snapshot restore use FSR for TiKV data volumes or not")
return cmd
}

Expand Down
7 changes: 7 additions & 0 deletions cmd/backup-manager/app/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type Options struct {
Prepare bool
// TargetAZ indicates which az the volume snapshots restore to. It's used in volume-snapshot mode.
TargetAZ string
// UseFSR to indicate if use FSR for TiKV data volumes during EBS snapshot restore
UseFSR bool
}

func (ro *Options) restoreData(
Expand Down Expand Up @@ -106,6 +108,11 @@ func (ro *Options) restoreData(
csbPath = path.Join(util.BRBinPath, "csb_restore.json")
args = append(args, fmt.Sprintf("--output-file=%s", csbPath))
args = append(args, fmt.Sprintf("--target-az=%s", ro.TargetAZ))
if ro.UseFSR == true {
args = append(args, fmt.Sprintf("--use-fsr=true"))
} else {
args = append(args, fmt.Sprintf("--use-fsr=false"))
}
progressStep = "Volume Restore"
} else {
progressStep = "Data Restore"
Expand Down
4 changes: 4 additions & 0 deletions cmd/backup-manager/app/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func validCmdFlagFunc(flag *pflag.Flag) {
return
}

if flag.Name == "use-fsr" {
return
}

cmdutil.CheckErr(fmt.Errorf(cmdHelpMsg, flag.Name))
}

Expand Down

0 comments on commit ee0b230

Please sign in to comment.