mirror of
https://github.com/restic/restic.git
synced 2025-12-08 06:09:56 +00:00
Merge pull request #5464 from wplapper/cmd_copy_v2
restic copy - add more status counters - issue #5175
This commit is contained in:
commit
d81f95c777
2 changed files with 28 additions and 0 deletions
9
changelog/unreleased/pull-5319
Normal file
9
changelog/unreleased/pull-5319
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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 specified.
|
||||
|
||||
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,21 @@ 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)
|
||||
for blob := range copyBlobs {
|
||||
for _, blob := range srcRepo.LookupBlob(blob.Type, blob.ID) {
|
||||
countBlobs++
|
||||
sizeBlobs += uint64(blob.Length)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
printer.V(" copy %d blobs with disk size %s in %d packfiles\n",
|
||||
countBlobs, ui.FormatBytes(uint64(sizeBlobs)), len(packList))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue