mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
prune: Abort if any used blobs are missing
The previous check only approximately verified whether all required blobs were found. However, after forgetting a few snapshots the repository contains lots of unused blobs whose number can be sufficient to make up for missing packs. When coupled with a malfunctioning backend that temporarily returns broken data this could cause restic to regard the corresponding packs as invalid and thereby delete data that's still in use. This change lets restic play it safe and refuse to delete anything if data is missing.
This commit is contained in:
parent
0fed6a8dfc
commit
3ba19869be
@ -191,10 +191,12 @@ func pruneRepository(gopts GlobalOptions, repo restic.Repository) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(usedBlobs) > stats.blobs {
|
for h := range usedBlobs {
|
||||||
return errors.Fatalf("number of used blobs is larger than number of available blobs!\n" +
|
if _, ok := blobCount[h]; !ok {
|
||||||
"Please report this error (along with the output of the 'prune' run) at\n" +
|
return errors.Fatalf("At least one data blob seems to be missing, aborting prune to prevent further data loss!\n" +
|
||||||
"https://github.com/restic/restic/issues/new")
|
"Please report this error (along with the output of the 'prune' run) at\n" +
|
||||||
|
"https://github.com/restic/restic/issues/new")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Verbosef("found %d of %d data blobs still in use, removing %d blobs\n",
|
Verbosef("found %d of %d data blobs still in use, removing %d blobs\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user