Id ... not found in repository

Hello,

I have a main repository and secondary repositorys which are clones of the main repository (to have offsite backups). The main repository should be intact as I ran the following commands on it:

restic prune --repack-small
restic rebuild-index --read-all-packs
restic check --read-data

On the secondary repository (to which I am copying) I ran the following commands:

restic copy --cleanup-cache
restic forget --keep-within ....
restic prune --repack-small
restic check --read-data

The command restic prune --repack-small fails:

$ restic prune --repack-small -r restic-repository                                                                                                                
enter password for repository: 
repository 725f6694 opened (version 2, compression level auto)
loading indexes...
loading all snapshots...
finding data that is still in use for 470 snapshots
[0:00] 0.21%  1 / 470 snapshots
id 2303d91f0a9066353a9cfb136ad6553f9336e4a70ff83acb61264ccdb81aeea6 not found in repository
github.com/restic/restic/internal/repository.(*Repository).LoadBlob
	github.com/restic/restic/internal/repository/repository.go:274
github.com/restic/restic/internal/restic.LoadTree
	github.com/restic/restic/internal/restic/tree.go:113
github.com/restic/restic/internal/restic.loadTreeWorker
	github.com/restic/restic/internal/restic/tree_stream.go:36
github.com/restic/restic/internal/restic.StreamTrees.func1
	github.com/restic/restic/internal/restic/tree_stream.go:176
golang.org/x/sync/errgroup.(*Group).Go.func1
	golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75
runtime.goexit
	runtime/asm_amd64.s:1598

restic check yields a long list of errors. Some of the form pack 06e31fb40331c7a1628ab01e7d20fdc07497fd12528743d2df182d6ab70755f7: not referenced in any index and pack cd0807bf54cf5e25d9c462b8613eb454714249c8556a8047398c5fd099df8103 contained in several indexes: {4608a282 877f98cd} (which are labelled as non-critial) and fatal ones:

error for tree 0beefbc7:
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77288.jpg" blob 71e3106f10d0f860140f1ed316bf739f0c6dd0a98d320c7e87d1fb44a3fe11d9 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77289.jpg" blob 78a89b9c43c26728172d442263ab28e2d7efbc31e8c3705a09431f93e73c9092 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77290.jpg" blob ab00fb5e890dd1b4834504299bfc6d9e6637df4bac50fd49b10ad0bcb84a3e99 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77291.jpg" blob 2371e2ec775c92a5d9e9b1c57e4037ddb52f627df48457b57e7a805646a4688e not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77300.jpg" blob 48939f799b4731ff01ed498f52b54b49ad96b208d63c13e0cdc67a1ebc56ecf5 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77301.jpg" blob 1672ff118fb6f2761c24b28408ee53aa3053b64d572b047327747815eb5dc55b not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77302.jpg" blob 93427453ddfe99a26aa232a714c86e86ee5f6a94e00c0133f03f19b1ecf88777 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77303.jpg" blob aade03912457de2cc0ba6c45828f80983a88d5a18c9d83910676cee82821ed7b not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77304.jpg" blob 2e4802e93017497d7a4f0fcd41e42785986bc41bce8d99b178fd4e8af09f0a83 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77305.jpg" blob d7bd6ebcc6451524fc1771a27932ed6533c281352fb409b0595ea311acb25a8c not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77306.jpg" blob 078b6ce8a240d7ce5fee35f06f3bfe81aa6c703a44ec9dbda9e3852250182416 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77307.jpg" blob 39123b1ae17e8fc52a87a33e7b93db34104bdcf6e7f7efa6a5cb62b949a6c299 not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77308.jpg" blob bbc8ffb40bea1c5a6fd4cda64e726923cd6cb57f6d90bc31ed394d64c9462a3c not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77309.jpg" blob 7ec71c2506b30aaa4f08e8fa5524f263745467159c5b86e6e512171eaf1c178f not found in index
  tree 0beefbc7e481ae55f34faf4edcc8dd3543c2489f230b81e49ca048d535b1be46: file "R 77317.jpg" blob 47a76cae9777b5d070c482e97bfcd20bf46d1a44431d24b20dc17469719e252f not found in index

How do I fix this?

Cheers

Which restic version are you using? And where are the repositories stored? Was the repository intact before the prune failure?

The first step is to use restic rebuild-index for the secondary repo; this ensures that restic is accurately able to tell which data actually exists in the repository. The repair steps afterwards depend a bit on what restic check reports afterwards.