diff --git a/cmd/backup.go b/cmd/backup.go index 0958e92db1e26..95e015e07889c 100644 --- a/cmd/backup.go +++ b/cmd/backup.go @@ -3,9 +3,11 @@ package cmd import ( + "github.com/pingcap/log" "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/session" "github.com/spf13/cobra" + "go.uber.org/zap" "github.com/pingcap/br/pkg/gluetikv" "github.com/pingcap/br/pkg/summary" @@ -19,7 +21,11 @@ func runBackupCommand(command *cobra.Command, cmdName string) error { command.SilenceUsage = false return err } - return task.RunBackup(GetDefaultContext(), tidbGlue, cmdName, &cfg) + if err := task.RunBackup(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil { + log.Error("failed to backup", zap.Error(err)) + return err + } + return nil } func runBackupRawCommand(command *cobra.Command, cmdName string) error { @@ -28,7 +34,11 @@ func runBackupRawCommand(command *cobra.Command, cmdName string) error { command.SilenceUsage = false return err } - return task.RunBackupRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg) + if err := task.RunBackupRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg); err != nil { + log.Error("failed to backup raw kv", zap.Error(err)) + return err + } + return nil } // NewBackupCommand return a full backup subcommand. diff --git a/cmd/restore.go b/cmd/restore.go index d4f2e8ec6ee78..494259ebb28e4 100644 --- a/cmd/restore.go +++ b/cmd/restore.go @@ -3,8 +3,10 @@ package cmd import ( + "github.com/pingcap/log" "github.com/pingcap/tidb/session" "github.com/spf13/cobra" + "go.uber.org/zap" "github.com/pingcap/br/pkg/gluetikv" "github.com/pingcap/br/pkg/summary" @@ -18,7 +20,11 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error { command.SilenceUsage = false return err } - return task.RunRestore(GetDefaultContext(), tidbGlue, cmdName, &cfg) + if err := task.RunRestore(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil { + log.Error("failed to restore", zap.Error(err)) + return err + } + return nil } func runRestoreRawCommand(command *cobra.Command, cmdName string) error { @@ -29,7 +35,11 @@ func runRestoreRawCommand(command *cobra.Command, cmdName string) error { command.SilenceUsage = false return err } - return task.RunRestoreRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg) + if err := task.RunRestoreRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg); err != nil { + log.Error("failed to restore raw kv", zap.Error(err)) + return err + } + return nil } func runRestoreTiflashReplicaCommand(command *cobra.Command, cmdName string) error { @@ -39,7 +49,11 @@ func runRestoreTiflashReplicaCommand(command *cobra.Command, cmdName string) err return err } - return task.RunRestoreTiflashReplica(GetDefaultContext(), tidbGlue, cmdName, &cfg) + if err := task.RunRestoreTiflashReplica(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil { + log.Error("failed to restore tiflash replica", zap.Error(err)) + return err + } + return nil } // NewRestoreCommand returns a restore subcommand.