From e7cdf2acbbb031819a5d472903e942bcb8c1410a Mon Sep 17 00:00:00 2001 From: Daniel Hoffend Date: Sun, 9 Feb 2020 02:02:45 +0100 Subject: [PATCH] fix backup --json total_bytes_processed output Closes #2429 --- changelog/unreleased/issue-2429 | 6 ++++++ internal/ui/jsonstatus/status.go | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/issue-2429 diff --git a/changelog/unreleased/issue-2429 b/changelog/unreleased/issue-2429 new file mode 100644 index 000000000..1ac52d11d --- /dev/null +++ b/changelog/unreleased/issue-2429 @@ -0,0 +1,6 @@ +Bugfix: backup --json reports total_bytes_processed as 0 + +We've fixed the json output of total_bytes_processed. The non-json output +was already fixed with pull request #2138 but left the json output untouched. + +https://github.com/restic/restic/issues/2429 diff --git a/internal/ui/jsonstatus/status.go b/internal/ui/jsonstatus/status.go index 3c8bc5545..d2969257a 100644 --- a/internal/ui/jsonstatus/status.go +++ b/internal/ui/jsonstatus/status.go @@ -49,6 +49,7 @@ type Backup struct { Changed uint Unchanged uint } + ProcessedBytes uint64 archiver.ItemStats } } @@ -214,6 +215,8 @@ func (b *Backup) CompleteItem(item string, previous, current *restic.Node, s arc done: true, } return + } else { + b.summary.ProcessedBytes += current.Size; } switch current.Type { @@ -360,7 +363,7 @@ func (b *Backup) Finish(snapshotID restic.ID) { TreeBlobs: b.summary.ItemStats.TreeBlobs, DataAdded: b.summary.ItemStats.DataSize + b.summary.ItemStats.TreeSize, TotalFilesProcessed: b.summary.Files.New + b.summary.Files.Changed + b.summary.Files.Unchanged, - TotalBytesProcessed: b.totalBytes, + TotalBytesProcessed: b.summary.ProcessedBytes, TotalDuration: time.Since(b.start).Seconds(), SnapshotID: snapshotID.Str(), })