forked from TrueCloudLab/restic
Merge pull request #614 from restic/improve-prune-stats
Improve statistics for `prune`
This commit is contained in:
commit
cf7795ce64
1 changed files with 16 additions and 4 deletions
|
@ -161,7 +161,8 @@ func (cmd CmdPrune) Execute(args []string) error {
|
||||||
}
|
}
|
||||||
bar.Done()
|
bar.Done()
|
||||||
|
|
||||||
cmd.global.Verbosef("found %d of %d data blobs still in use\n", len(usedBlobs), stats.blobs)
|
cmd.global.Verbosef("found %d of %d data blobs still in use, removing %d blobs\n",
|
||||||
|
len(usedBlobs), stats.blobs, stats.blobs-len(usedBlobs))
|
||||||
|
|
||||||
// find packs that need a rewrite
|
// find packs that need a rewrite
|
||||||
rewritePacks := restic.NewIDSet()
|
rewritePacks := restic.NewIDSet()
|
||||||
|
@ -176,15 +177,25 @@ func (cmd CmdPrune) Execute(args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeBytes := 0
|
||||||
|
|
||||||
// find packs that are unneeded
|
// find packs that are unneeded
|
||||||
removePacks := restic.NewIDSet()
|
removePacks := restic.NewIDSet()
|
||||||
nextPack:
|
|
||||||
for packID, p := range idx.Packs {
|
for packID, p := range idx.Packs {
|
||||||
|
|
||||||
|
hasActiveBlob := false
|
||||||
for _, blob := range p.Entries {
|
for _, blob := range p.Entries {
|
||||||
h := restic.BlobHandle{ID: blob.ID, Type: blob.Type}
|
h := restic.BlobHandle{ID: blob.ID, Type: blob.Type}
|
||||||
if usedBlobs.Has(h) {
|
if usedBlobs.Has(h) {
|
||||||
continue nextPack
|
hasActiveBlob = true
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeBytes += int(blob.Length)
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasActiveBlob {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
removePacks.Insert(packID)
|
removePacks.Insert(packID)
|
||||||
|
@ -196,7 +207,8 @@ nextPack:
|
||||||
rewritePacks.Delete(packID)
|
rewritePacks.Delete(packID)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.global.Verbosef("will delete %d packs and rewrite %d packs\n", len(removePacks), len(rewritePacks))
|
cmd.global.Verbosef("will delete %d packs and rewrite %d packs, this frees %s\n",
|
||||||
|
len(removePacks), len(rewritePacks), formatBytes(uint64(removeBytes)))
|
||||||
|
|
||||||
err = repository.Repack(repo, rewritePacks, usedBlobs)
|
err = repository.Repack(repo, rewritePacks, usedBlobs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue