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.
This commit is contained in:
Winfried Plappert 2025-10-05 07:42:27 +01:00 committed by Michael Eischer
parent 90ac3efa88
commit 25611f4628
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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))
}