From d0590b784192e305051185e90b9eb83c0f0789eb Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 17 Jul 2022 12:05:04 +0200 Subject: [PATCH] prune: Add internal integrity check After repacking every blob that should be kept must have been repacked. We have seen a few cases in which a single blob went missing, which could have been caused by a bitflip somewhere. This sanity check might help catch some of these cases. --- cmd/restic/cmd_prune.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 0b12ffc1a..7687a9b83 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -658,6 +658,14 @@ func doPrune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, pla // Also remove repacked packs plan.removePacks.Merge(plan.repackPacks) + + if len(plan.keepBlobs) != 0 { + Warnf("%v was not repacked\n\n"+ + "Integrity check failed.\n"+ + "Please report this error (along with the output of the 'prune' run) at\n"+ + "https://github.com/restic/restic/issues/new/choose\n", plan.keepBlobs) + return errors.Fatal("internal error: blobs were not repacked") + } } if len(plan.ignorePacks) == 0 {