Show restore progress details
This commit is contained in:
@@ -732,13 +732,35 @@ func (s *Service) executeRestore(ctx context.Context, run model.Run) model.Run {
|
||||
defer s.mounts.Cleanup(context.Background(), mounted)
|
||||
appendLiveLog(&live, "Restic stellt den Snapshot wieder her")
|
||||
s.updateActive(live)
|
||||
if err := s.restic.Restore(ctx, mounted.Repository, task); err != nil {
|
||||
lastLoggedPercent := -10
|
||||
started := time.Now()
|
||||
if err := s.restic.Restore(ctx, mounted.Repository, task, func(progress restic.Progress) {
|
||||
live.ProgressPercent = progress.PercentDone * 100
|
||||
live.ProgressBytes, live.ProgressTotal = progress.BytesDone, progress.TotalBytes
|
||||
live.ProgressFiles, live.ProgressFileTotal = progress.FilesDone, progress.TotalFiles
|
||||
live.SecondsRemaining = progress.SecondsRemaining
|
||||
if elapsed := time.Since(started).Seconds(); elapsed > 0 {
|
||||
live.BytesPerSecond = float64(progress.BytesDone) / elapsed
|
||||
}
|
||||
if len(progress.CurrentFiles) > 0 {
|
||||
live.CurrentFile = progress.CurrentFiles[len(progress.CurrentFiles)-1]
|
||||
}
|
||||
percent := int(live.ProgressPercent)
|
||||
if percent >= lastLoggedPercent+10 {
|
||||
appendLiveLog(&live, fmt.Sprintf("Restore-Fortschritt: %.1f%%, %d/%d Dateien, %s/%s", live.ProgressPercent, live.ProgressFiles, live.ProgressFileTotal, formatBytes(live.ProgressBytes), formatBytes(live.ProgressTotal)))
|
||||
lastLoggedPercent = percent - percent%10
|
||||
}
|
||||
s.updateActive(live)
|
||||
}); err != nil {
|
||||
failedRun := failedError(run, err)
|
||||
appendLiveLog(&live, "Restore fehlgeschlagen: "+err.Error())
|
||||
failedRun.LiveLog = live.LiveLog
|
||||
return failedRun
|
||||
}
|
||||
run.Status, run.Message, run.JobID = "success", "restore completed", ""
|
||||
run.Status, run.Message = "success", "restore completed"
|
||||
run.ProgressPercent, run.ProgressBytes, run.ProgressTotal = 100, live.ProgressBytes, live.ProgressTotal
|
||||
run.ProgressFiles, run.ProgressFileTotal = live.ProgressFiles, live.ProgressFileTotal
|
||||
run.BytesPerSecond, run.SecondsRemaining, run.CurrentFile = live.BytesPerSecond, 0, live.CurrentFile
|
||||
appendLiveLog(&live, "Restore abgeschlossen")
|
||||
run.LiveLog = live.LiveLog
|
||||
return run
|
||||
|
||||
Reference in New Issue
Block a user