Fix broken snapshots via restic repair snapshots --forget (#21907)

Co-authored-by: Michael Eischer <michael.eischer@fau.de>
This commit is contained in:
Winfried Plappert
2026-06-27 22:09:10 +02:00
committed by GitHub
co-authored by Michael Eischer
parent aa94be2dbd
commit 9e1a526611
7 changed files with 171 additions and 18 deletions
+11 -2
View File
@@ -132,6 +132,11 @@ func (f *SnapshotFilter) FindAll(ctx context.Context, be restic.Lister, loader r
var err error
usedFilter := false
be, err := restic.MemorizeList(ctx, be, restic.SnapshotFile)
if err != nil {
return err
}
ids := restic.NewIDSet()
// Process all snapshot IDs given as arguments.
for _, s := range snapshotIDs {
@@ -181,14 +186,18 @@ func (f *SnapshotFilter) FindAll(ctx context.Context, be restic.Lister, loader r
if !usedFilter && !f.Empty() {
return fn("filters", nil, errors.Errorf("explicit snapshot ids are given"))
}
return nil
return ctx.Err()
}
return ForAllSnapshots(ctx, be, loader, nil, func(id restic.ID, sn *Snapshot, err error) error {
err := ForAllSnapshots(ctx, be, loader, nil, func(id restic.ID, sn *Snapshot, err error) error {
if err == nil && !f.matches(sn) {
return nil
}
return fn(id.String(), sn, err)
})
if err != nil {
return err
}
return ctx.Err()
}