Skip to content

Commit

Permalink
fix: live backup progress updates with partial-backup errors
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Feb 17, 2024
1 parent 663b430 commit 83a6d06
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/orchestrator/taskbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ func backupHelper(ctx context.Context, t Task, orchestrator *Orchestrator, plan
lastSent := time.Now() // debounce progress updates, these can endup being very frequent.
var lastFiles []string
summary, err := repo.Backup(ctx, plan, func(entry *restic.BackupProgressEntry) {
if time.Since(lastSent) < 250*time.Millisecond {
return
}
lastSent = time.Now()

if entry.MessageType == "status" {
// prevents flickering output when a status entry omits the CurrentFiles property. Largely cosmetic.
Expand All @@ -130,9 +126,6 @@ func backupHelper(ctx context.Context, t Task, orchestrator *Orchestrator, plan
}

backupOp.OperationBackup.LastStatus = protoutil.BackupProgressEntryToProto(entry)
if err := orchestrator.OpLog.Update(op); err != nil {
zap.S().Errorf("failed to update oplog with progress for backup: %v", err)
}
} else if entry.MessageType == "error" {
zap.S().Warnf("backup error: %v", entry.Error)
backupError, err := protoutil.BackupProgressEntryToBackupError(entry)
Expand All @@ -148,6 +141,15 @@ func backupHelper(ctx context.Context, t Task, orchestrator *Orchestrator, plan
} else if entry.MessageType != "summary" {
zap.S().Warnf("unexpected message type %q in backup progress entry", entry.MessageType)
}

if time.Since(lastSent) < 500*time.Millisecond {
return
}
lastSent = time.Now()

if err := orchestrator.OpLog.Update(op); err != nil {
zap.S().Errorf("failed to update oplog with progress for backup: %v", err)
}
})

vars := hook.HookVars{
Expand Down

0 comments on commit 83a6d06

Please sign in to comment.