From 90ac3efa889508bd1d5947381a8720ff5b752195 Mon Sep 17 00:00:00 2001 From: Winfried Plappert <18740761+wplapper@users.noreply.github.com> Date: Mon, 4 Aug 2025 12:39:26 +0100 Subject: [PATCH 1/4] restic copy - add additional status counters 'copyTree()' now counts and sizes the blobs in 'copyBlobs' and prints them out via 'Verbosef()'. --- changelog/unreleased/pull-5319 | 8 ++++++++ cmd/restic/cmd_copy.go | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 changelog/unreleased/pull-5319 diff --git a/changelog/unreleased/pull-5319 b/changelog/unreleased/pull-5319 new file mode 100644 index 000000000..e4c1f0865 --- /dev/null +++ b/changelog/unreleased/pull-5319 @@ -0,0 +1,8 @@ +Enhancement: add more status counters to `restic copy` + +`restic copy` now produces more status counters in text format. The new counters +are the number of tree/data blobs, their sizes and the number of packfiles +they are attachedc to. + +https://github.com/restic/restic/issues/5175 +https://github.com/restic/restic/pull/5319 diff --git a/cmd/restic/cmd_copy.go b/cmd/restic/cmd_copy.go index 096ce76c6..2281e9d05 100644 --- a/cmd/restic/cmd_copy.go +++ b/cmd/restic/cmd_copy.go @@ -242,6 +242,7 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep return err } + copyStats(srcRepo, copyBlobs, packList, printer) bar := printer.NewCounter("packs copied") err = repository.Repack(ctx, srcRepo, dstRepo, packList, copyBlobs, bar, printer.P) if err != nil { @@ -249,3 +250,19 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep } return nil } + +func copyStats(srcRepo restic.Repository, copyBlobs restic.BlobSet, packList restic.IDSet, printer progress.Printer) { + // count and size + countBlobs := 0 + sizeBlobs := uint64(0) + for blob := range copyBlobs { + for _, blob := range srcRepo.LookupBlob(blob.Type, blob.ID) { + countBlobs++ + sizeBlobs += uint64(blob.Length) + } + break + } + + printer.V(" %7d all blobs with a size %11s in %7d packfiles\n", + countBlobs, ui.FormatBytes(uint64(sizeBlobs)), len(packList)) +} From 25611f4628e885d0a935b57574b87b948ce77201 Mon Sep 17 00:00:00 2001 From: Winfried Plappert <18740761+wplapper@users.noreply.github.com> Date: Sun, 5 Oct 2025 07:42:27 +0100 Subject: [PATCH 2/4] restic copy - add statistics counters cmd/restic/cmd_copy.go: add function copyStats() and call it before the actual copying starts. changelog/unreleased/pull-5319: rephrased wording of the statistics counters. --- changelog/unreleased/pull-5319 | 4 ++-- cmd/restic/cmd_copy.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/changelog/unreleased/pull-5319 b/changelog/unreleased/pull-5319 index e4c1f0865..a512c3613 100644 --- a/changelog/unreleased/pull-5319 +++ b/changelog/unreleased/pull-5319 @@ -1,8 +1,8 @@ Enhancement: add more status counters to `restic copy` `restic copy` now produces more status counters in text format. The new counters -are the number of tree/data blobs, their sizes and the number of packfiles -they are attachedc to. +are the number of blobs to copy, their size on disk and the number of packfiles +used from the source repository. https://github.com/restic/restic/issues/5175 https://github.com/restic/restic/pull/5319 diff --git a/cmd/restic/cmd_copy.go b/cmd/restic/cmd_copy.go index 2281e9d05..498d6f75d 100644 --- a/cmd/restic/cmd_copy.go +++ b/cmd/restic/cmd_copy.go @@ -251,7 +251,9 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep return nil } +// copyStats: print statistics for the blobs to be copied func copyStats(srcRepo restic.Repository, copyBlobs restic.BlobSet, packList restic.IDSet, printer progress.Printer) { + // count and size countBlobs := 0 sizeBlobs := uint64(0) @@ -259,10 +261,10 @@ func copyStats(srcRepo restic.Repository, copyBlobs restic.BlobSet, packList res for _, blob := range srcRepo.LookupBlob(blob.Type, blob.ID) { countBlobs++ sizeBlobs += uint64(blob.Length) + break } - break } - printer.V(" %7d all blobs with a size %11s in %7d packfiles\n", + printer.V(" copy %d blobs with disk size %s in %d packfiles\n", countBlobs, ui.FormatBytes(uint64(sizeBlobs)), len(packList)) } From 1e3b96bf99bc415fa1761b55217b13c6a7e2ea78 Mon Sep 17 00:00:00 2001 From: Winfried Plappert <18740761+wplapper@users.noreply.github.com> Date: Mon, 6 Oct 2025 06:18:40 +0100 Subject: [PATCH 3/4] restic copy - statistics feature reword the description od the PR --- changelog/unreleased/pull-5319 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog/unreleased/pull-5319 b/changelog/unreleased/pull-5319 index a512c3613..1e7c4c869 100644 --- a/changelog/unreleased/pull-5319 +++ b/changelog/unreleased/pull-5319 @@ -2,7 +2,8 @@ Enhancement: add more status counters to `restic copy` `restic copy` now produces more status counters in text format. The new counters are the number of blobs to copy, their size on disk and the number of packfiles -used from the source repository. +used from the source repository. The additional statistics is only produced when +the `--verbose` option is apecified. https://github.com/restic/restic/issues/5175 https://github.com/restic/restic/pull/5319 From 3b71c447556d78c24edb65ce9b34dd6c305258ac Mon Sep 17 00:00:00 2001 From: Winfried Plappert <18740761+wplapper@users.noreply.github.com> Date: Tue, 7 Oct 2025 08:07:29 +0100 Subject: [PATCH 4/4] restic copy - stattistics counters fixed typo in changelog/unreleased/pull-5319 --- changelog/unreleased/pull-5319 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/pull-5319 b/changelog/unreleased/pull-5319 index 1e7c4c869..ae1e5fdf1 100644 --- a/changelog/unreleased/pull-5319 +++ b/changelog/unreleased/pull-5319 @@ -3,7 +3,7 @@ Enhancement: add more status counters to `restic copy` `restic copy` now produces more status counters in text format. The new counters are the number of blobs to copy, their size on disk and the number of packfiles used from the source repository. The additional statistics is only produced when -the `--verbose` option is apecified. +the `--verbose` option is specified. https://github.com/restic/restic/issues/5175 https://github.com/restic/restic/pull/5319