mirror of
https://github.com/restic/restic.git
synced 2026-02-03 04:20:45 -05:00
restic copy - add additional status counters
'copyTree()' now counts and sizes the blobs in 'copyBlobs' and prints them out via 'Verbosef()'.
This commit is contained in:
parent
5b173d2206
commit
90ac3efa88
2 changed files with 25 additions and 0 deletions
8
changelog/unreleased/pull-5319
Normal file
8
changelog/unreleased/pull-5319
Normal file
|
|
@ -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
|
||||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue