Skip to content

[Draft] feat(restore): select artifacts to restore with --include patterns #2367

Done

Description

@TerryHowe

Note

Draft: this depends on the proposal in #2358, which is still a draft, and builds on Mode 1 (#2364, implemented in #2376). The details may change before #2358 is agreed.

What

Support selective restore: restore only some of the repositories, or some of the tags, from a backup. This is Mode 2 in the multi-repository backup/restore proposal (#2358).

What to restore is chosen with repeatable --include patterns that match the source references stored in the backup. The positional argument stays the destination only, <target-registry>[/<namespace>], exactly as in Mode 1:

oras restore [flags] --input <path> --include <pattern> [--include <pattern>...] <target-registry>[/<namespace>]
oras restore --input base-images.tar \
  --include library/alpine \
  --include library/busybox:1.36.1 \
  registry.mycompany.com
In backup Restored to
docker.io/library/alpine:3.19.0 registry.mycompany.com/library/alpine:3.19.0
docker.io/library/busybox:1.36.1 registry.mycompany.com/library/busybox:1.36.1
docker.io/library/nginx:1.25-alpine skipped

Keeping selection out of the target argument means a selector is never mistaken for a destination. #2376 already rejects a tag or digest in the target, so registry.mycompany.com/library/alpine:3.19.0 is an error, not a filter.

Pattern syntax

[<registry>/]<repository>[:<tag>]

  • The pattern is split into a repository part and a tag part at the last : after the last /. A : before the last / is a registry port: registry.lan:5000/app has no tag part, registry.lan:5000/app:v1 has tag part v1.
  • The repository part matches a stored <registry>/<repository> in full, or without its registry.
  • The tag part matches the stored tag. Without a tag part, every tag of the matching repositories is selected.
  • * matches any sequence of characters, including /, within its own part. It never crosses from repository into tag.
  • Patterns are compared literally. Docker Hub short names are not expanded: alpine does not match docker.io/library/alpine.
  • A pattern without a / is a repository, never a registry: registry.lan:5000 is repository registry.lan with tag 5000. To select everything from a registry, use registry.lan:5000/*.
  • Because the repository part is also tried against the full <registry>/<repository>, a leading * can match the registry: */alpine matches docker.io/library/alpine.
  • Digests (@sha256:...), an empty repository part, and an empty tag part (library/alpine:) are rejected.
Pattern Selects
library/alpine every tag of library/alpine, from any source registry
docker.io/library/alpine every tag of library/alpine from docker.io only
library/alpine:3.19.0 one tag
library/alpine:3.* tags of library/alpine starting with 3.
*:v1 tag v1 in every repository
library/* every repository under library/
registry.lan:5000/app every tag of app from registry.lan:5000
registry.lan:5000/* every repository from registry.lan:5000

Scope

  • Add a repeatable --include <pattern> flag to oras restore. An artifact is restored if it matches any pattern.
  • Parse and match patterns as above.
  • Map selected artifacts exactly as Mode 1 does (restoreTargets), including --preserve-source-registry and the collision check. If a pattern selects the same path under more than one source registry (e.g. docker.io/library/nginx and mirror.gcr.io/library/nginx), the collision error applies; its recommendation should also suggest adding the registry to the pattern. Selection happens before mapping, so the collision check sees only the selected artifacts: restoring one of two colliding repositories succeeds.
  • Fail before anything is pushed if a pattern matches nothing. The error lists stored repositories whose last path component equals the pattern's (e.g. "did you mean library/alpine?"). No suggestion is made when that component contains *.
  • Tag-only entries from backups created by earlier versions have no repository. Only patterns whose repository part is exactly * match them (*, *:v1); a pattern that names a repository never matches them.
  • Report restored and skipped repositories, including in --dry-run. The found-tags line shows how many tags were selected out of how many are in the backup, and the completion summary counts only restored tags. Run every pre-push check (unmatched patterns, collisions, invalid target names) in --dry-run too.
  • Update the help text and examples.
  • Unit tests for pattern parsing and matching (ports, port-only patterns, * in each part and across /, short names, tag-only entries, rejected digests) and for a selection that avoids a collision in the full backup. e2e tests for selective restore and an unmatched pattern.

Not in scope

  • --exclude with the same syntax. It can be added later.
  • Restoring under a different repository name. That needs a rules file (Mode 3).
  • Rejecting --include together with --rules. --rules does not exist yet; Mode 3 adds that check when it adds the flag.
  • Wildcards on oras backup. Backup still takes explicit references only.

Refs #1917, #2358, #2364, #2376

Activity

  1. added
    enhancement
    experimental
    triage
    on Nov 25, 2026
  2. changed the title [-][Draft] feat(restore): selective restore of repositories and tags from a multi-repository backup[/-] [+][Draft] feat(restore): select artifacts to restore with --include patterns[/+] on Nov 27, 2026
  3. TerryHowe commented on Nov 27, 2026

    @TerryHowe
    MemberAuthor

    Rewrote this issue to match the current proposal in #2358: Mode 2 now selects artifacts with repeatable --include patterns matched against the source references, and the positional argument stays <target-registry>[/<namespace>] as in Mode 1 (#2376). Positional target repositories and <target-repo>:<tag> selection are dropped; #2376 already rejects a tag or digest in the target. The open questions are answered: a single repository can be restored with one --include, and Modes 1 and 2 restore to one target registry, while restoring to several registries is left to rules files (Mode 3).

  4. Orion777-cmd commented on Nov 28, 2026

    @Orion777-cmd
    Contributor

    I'd be glad to take this one too, since it builds on #2376 and #2402.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementexperimentaltriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions