diff --git a/changelogs/unreleased/7586-Lyndon-Li b/changelogs/unreleased/7586-Lyndon-Li new file mode 100644 index 0000000000..c40616bd03 --- /dev/null +++ b/changelogs/unreleased/7586-Lyndon-Li @@ -0,0 +1 @@ +Fix issue #7535, add the MustHave resource check during item collection and item filter for restore \ No newline at end of file diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index fd900b54c8..45b76264ee 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -1123,7 +1123,7 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso // Check if group/resource should be restored. We need to do this here since // this method may be getting called for an additional item which is a group/resource // that's excluded. - if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) { + if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) && !ctx.resourceMustHave.Has(groupResource.String()) { restoreLogger.Info("Not restoring item because resource is excluded") return warnings, errs, itemExists } @@ -2198,7 +2198,7 @@ func (ctx *restoreContext) getOrderedResourceCollection( // Check if the resource should be restored according to the resource // includes/excludes. - if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) { + if !ctx.resourceIncludesExcludes.ShouldInclude(groupResource.String()) && !ctx.resourceMustHave.Has(groupResource.String()) { ctx.log.WithField("resource", groupResource.String()).Infof("Skipping restore of resource because the restore spec excludes it") continue }