From b71c52797a5c43ea2c5c3bbb995cdab3415c67f0 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 28 Jan 2021 21:21:54 +0100 Subject: [PATCH 1/4] find: correctly expand multiple blob ids For example `restic find --show-pack-id --blob f78dc991 5b9e4366 ddd8c7d4` would previously only expand one blob if all of them belong to the same file. --- cmd/restic/cmd_find.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index f7b9e4c73..0986b5a13 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -394,7 +394,6 @@ func (f *Finder) findIDs(ctx context.Context, sn *restic.Snapshot) error { delete(f.blobIDs, idStr[:shortStr]) } f.out.PrintObject("blob", idStr, nodepath, parentTreeID.String(), sn) - break } } From ff95999246c39a73f0af23fff706628f0fbd5d33 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 28 Jan 2021 21:27:41 +0100 Subject: [PATCH 2/4] rebuild-index: report added/removed/reindexed files This should help with investigating missing pack files. --- cmd/restic/cmd_rebuild_index.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/restic/cmd_rebuild_index.go b/cmd/restic/cmd_rebuild_index.go index 3af5af29e..2ac7b2613 100644 --- a/cmd/restic/cmd_rebuild_index.go +++ b/cmd/restic/cmd_rebuild_index.go @@ -88,6 +88,11 @@ func rebuildIndex(opts RebuildIndexOptions, gopts GlobalOptions, repo *repositor packSizeFromList[id] = packSize removePacks.Insert(id) } + if !ok { + Warnf("adding pack file to index %v\n", id) + } else if size != packSize { + Warnf("reindexing pack file %v with unexpected size %v instead of %v\n", id, packSize, size) + } delete(packSizeFromIndex, id) return nil }) @@ -98,6 +103,7 @@ func rebuildIndex(opts RebuildIndexOptions, gopts GlobalOptions, repo *repositor // forget pack files that are referenced in the index but do not exist // when rebuilding the index removePacks.Insert(id) + Warnf("removing not found pack file %v\n", id) } if len(packSizeFromList) > 0 { From 7b8886c052716407980fcbda8f4428ba107a6f36 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 28 Jan 2021 21:42:26 +0100 Subject: [PATCH 3/4] prune: report missing but unneeded pack files This indicates a damaged repository so add some output to help with debugging. --- cmd/restic/cmd_prune.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 777cf616b..19cd4c525 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -378,7 +378,10 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB return errorPacksMissing } if len(ignorePacks) != 0 { - Verbosef("missing but unneded pack files are referenced in the index, will be repaired\n") + Warnf("Missing but unneeded pack files are referenced in the index, will be repaired\n") + for id := range ignorePacks { + Warnf("will forget missing pack file %v\n", id) + } } repackAllPacksWithDuplicates := true From 58b5679f147cc197baeedc873a7041e162b33edb Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 28 Jan 2021 21:48:24 +0100 Subject: [PATCH 4/4] prune: reword missing blobs error The previous wording could be understood such that the prune run did damage the repository. --- cmd/restic/cmd_prune.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 19cd4c525..6f7e1874c 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -245,8 +245,9 @@ func prune(opts PruneOptions, gopts GlobalOptions, repo restic.Repository, usedB // Check if all used blobs have been found in index if len(usedBlobs) != 0 { - Warnf("%v not found in the index\n"+ - "Data blobs seem to be missing, aborting prune to prevent further data loss!\n"+ + Warnf("%v not found in the index\n\n"+ + "Integrity check failed: Data seems to be missing.\n"+ + "Will not start prune to prevent (additional) data loss!\n"+ "Please report this error (along with the output of the 'prune' run) at\n"+ "https://github.com/restic/restic/issues/new/choose", usedBlobs) return errorIndexIncomplete