Skip to content

Commit

Permalink
fix(redis): 修复dbmon中一些备份bug TencentBlueKing#7026
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemakeit committed Sep 23, 2024
1 parent 73276af commit 90009e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,13 @@ func (job *Job) CheckOldBinlogBackupStatus(port int) {
// taskStatus==4,上传成功;
// taskStatus<4,上传中;
if taskStatus > 4 {
if row.Status != consts.BackupStatusToBakSystemFailed { // 失败状态不重复上报
if row.Status != consts.BackupStatusToBakSystemFailed &&
time.Now().Local().Sub(row.StartTime) > 1*time.Hour {
// 如果上传失败,且距离文件生成时间超过1小时,则上报
row.Status = consts.BackupStatusToBakSystemFailed
row.Message = fmt.Sprintf("上传失败,err:%s", statusMsg)
row.Message = fmt.Sprintf("上传失败,statusCode:%d,err:%s", taskStatus, statusMsg)
row.BackupRecordReport(job.Reporter)
mylog.Logger.Error(fmt.Sprintf("%s %s", row.BackupFile, row.Message))
}
} else if taskStatus < 4 {
// 上传中,下次继续探测
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (task *Task) mvBinlogToBackupDir() {
filename := filepath.Base(task.BackupFile)
var mvCmd string
var targetName, targetFullPath string
if strings.Contains(filename, strconv.Itoa(task.ServerPort)) {
if strings.Contains(filename, "-"+strconv.Itoa(task.ServerPort)+"-") {
// binlog-30012-0007515-20221110084710.log => binlog-1.1.1.1-30012-0007515-20221110084710.log
targetName = strings.Replace(filename, "binlog-", "binlog-"+task.ServerIP+"-", -1)
targetFullPath = filepath.Join(task.BackupDir, targetName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,13 @@ func (job *Job) CheckOldFullbackupStatus(port int) {
// taskStatus==4,上传成功;
// taskStatus<4,上传中;
if taskStatus > 4 {
if row.Status != consts.BackupStatusToBakSystemFailed { // 失败状态不重复上报
if row.Status != consts.BackupStatusToBakSystemFailed &&
time.Now().Local().Sub(row.StartTime) > 1*time.Hour {
// 如果上传失败,且距离文件生成时间超过1小时,则上报
row.Status = consts.BackupStatusToBakSystemFailed
row.Message = fmt.Sprintf("上传失败,err:%s", statusMsg)
row.Message = fmt.Sprintf("上传失败,statusCode:%d,err:%s", taskStatus, statusMsg)
row.BackupRecordReport(job.Reporter)
mylog.Logger.Error(fmt.Sprintf("%s %s", row.BackupFile, row.Message))
}
} else if taskStatus < 4 {
// 上传中,下次继续探测
Expand Down

0 comments on commit 90009e5

Please sign in to comment.