diff --git a/backend/init/migration/migrations/v_1_9.go b/backend/init/migration/migrations/v_1_9.go index 5c21f4872..551684811 100644 --- a/backend/init/migration/migrations/v_1_9.go +++ b/backend/init/migration/migrations/v_1_9.go @@ -314,9 +314,9 @@ var UpdateCronjobSpec = &gormigrate.Migration{ } var records []model.JobRecords - _ = tx.Where("cronjob_id = ? AND status = ?", job.ID, constant.StatusSuccess).Find(&records).Error + _ = tx.Where("cronjob_id = ?", job.ID).Find(&records).Error for _, record := range records { - if job.Type == "snapshot" { + if job.Type == "snapshot" && job.Status == constant.StatusSuccess { var snaps []model.Snapshot _ = tx.Where("name like ?", "snapshot_"+"%").Find(&snaps).Error for _, snap := range snaps { @@ -337,7 +337,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{ } continue } - if job.Type == "log" { + if job.Type == "log" && job.Status == constant.StatusSuccess { item := model.BackupRecord{ From: "cronjob", CronjobID: job.ID, @@ -354,7 +354,7 @@ var UpdateCronjobSpec = &gormigrate.Migration{ _ = tx.Create(&item).Error continue } - if job.Type == "directory" { + if job.Type == "directory" && job.Status == constant.StatusSuccess { item := model.BackupRecord{ From: "cronjob", CronjobID: job.ID, diff --git a/backend/utils/cloud_storage/client/sftp.go b/backend/utils/cloud_storage/client/sftp.go index 17e828e1a..749e796c8 100644 --- a/backend/utils/cloud_storage/client/sftp.go +++ b/backend/utils/cloud_storage/client/sftp.go @@ -34,6 +34,9 @@ func NewSftpClient(vars map[string]interface{}) (*sftpClient, error) { return nil }, } + if _, err := ssh.Dial("tcp", fmt.Sprintf("%s:%s", address, port), clientConfig); err != nil { + return nil, err + } return &sftpClient{bucket: bucket, connInfo: fmt.Sprintf("%s:%s", address, port), config: clientConfig}, nil }