diff --git a/cmd/backup-manager/app/backup/manager.go b/cmd/backup-manager/app/backup/manager.go index f5d30dcdb89..b0d3b712da0 100644 --- a/cmd/backup-manager/app/backup/manager.go +++ b/cmd/backup-manager/app/backup/manager.go @@ -35,6 +35,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" errorutils "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" ) @@ -101,6 +102,13 @@ func (bm *Manager) ProcessBackup() error { return errorutils.NewAggregate(errs) } + crData, err := json.Marshal(backup) + if err != nil { + klog.Errorf("failed to marshal backup %v to json, err: %v", backup, err) + } else { + klog.Infof("start to process backup: %s", string(crData)) + } + // we treat snapshot backup as restarted if its status is not scheduled when backup pod just start to run // we will clean backup data before run br command if backup.Spec.Mode == v1alpha1.BackupModeSnapshot && (backup.Status.Phase != v1alpha1.BackupScheduled || v1alpha1.IsBackupRestart(backup)) { @@ -132,6 +140,9 @@ func (bm *Manager) ProcessBackup() error { return bm.performBackup(ctx, backup.DeepCopy(), nil) } + klog.Infof("start to connect to tidb server (%s:%d) as the .spec.from field is specified", + backup.Spec.From.Host, backup.Spec.From.Port) + // validate and create from db var db *sql.DB db, err = bm.validateAndCreateFromDB(ctx, backup.DeepCopy()) diff --git a/cmd/backup-manager/app/export/manager.go b/cmd/backup-manager/app/export/manager.go index 6bedab45178..49edfa18683 100644 --- a/cmd/backup-manager/app/export/manager.go +++ b/cmd/backup-manager/app/export/manager.go @@ -32,6 +32,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" errorutils "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" ) @@ -99,6 +100,13 @@ func (bm *BackupManager) ProcessBackup() error { return errorutils.NewAggregate(errs) } + crData, err := json.Marshal(backup) + if err != nil { + klog.Errorf("failed to marshal backup %v to json, err: %v", backup, err) + } else { + klog.Infof("start to process backup: %s", string(crData)) + } + reason, err := bm.setOptions(backup) if err != nil { errs = append(errs, err) diff --git a/cmd/backup-manager/app/import/manager.go b/cmd/backup-manager/app/import/manager.go index 36e4db7e37c..cdeb15737a4 100644 --- a/cmd/backup-manager/app/import/manager.go +++ b/cmd/backup-manager/app/import/manager.go @@ -27,6 +27,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" errorutils "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/apimachinery/pkg/util/json" "k8s.io/klog/v2" ) @@ -87,6 +88,13 @@ func (rm *RestoreManager) ProcessRestore() error { return errorutils.NewAggregate(errs) } + crData, err := json.Marshal(restore) + if err != nil { + klog.Errorf("failed to marshal restore %v to json, err: %s", restore, err) + } else { + klog.Infof("start to process restore: %s", string(crData)) + } + rm.setOptions(restore) return rm.performRestore(ctx, restore.DeepCopy()) diff --git a/cmd/backup-manager/app/restore/manager.go b/cmd/backup-manager/app/restore/manager.go index 5ba497f7bae..da9bf95c620 100644 --- a/cmd/backup-manager/app/restore/manager.go +++ b/cmd/backup-manager/app/restore/manager.go @@ -30,6 +30,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" errorutils "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" ) @@ -96,12 +97,22 @@ func (rm *Manager) ProcessRestore() error { return fmt.Errorf("no br config in %s", rm) } + crData, err := json.Marshal(restore) + if err != nil { + klog.Errorf("failed to marshal restore %v to json, err: %s", restore, err) + } else { + klog.Infof("start to process restore: %s", string(crData)) + } + if restore.Spec.To == nil { return rm.performRestore(ctx, restore.DeepCopy(), nil) } rm.setOptions(restore) + klog.Infof("start to connect to tidb server (%s:%d) as the .spec.to field is specified", + restore.Spec.To.Host, restore.Spec.To.Port) + var db *sql.DB var dsn string err = wait.PollImmediate(constants.PollInterval, constants.CheckTimeout, func() (done bool, err error) {