Skip to content

feat(restore): restore multi-repository backups to <registry>[/<namespace>] #2364

Done

Description

@TerryHowe

What

Support restoring a backup that holds several repositories to a target registry, optionally under a namespace. This is Mode 1 ("Direct Restore") in the multi-repository backup/restore proposal (#2358):

oras restore --input <path> <target-registry>[/<namespace>]

Each source registry host is dropped and the repository path is kept under the target:

oras restore --input backup.tar harbor.local/myproject
Stored reference (ref.name) Restored to
docker.io/library/redis:7.2-alpine harbor.local/myproject/library/redis:7.2-alpine
ghcr.io/oras-project/oras:v1.3.0 harbor.local/myproject/oras-project/oras:v1.3.0

Why

Since #1904, oras backup stores the full reference (<registry>/<repository>:<tag>) in org.opencontainers.image.ref.name. Restore only extracts the tag and pushes everything to one <repository>. So a backup containing two repositories with the same tag (a:v1 and b:v1) is rejected as a duplicate, and the repository paths in the backup are lost.

Scope

  • Always treat the positional argument as <target-registry>[/<namespace>], however many repositories the backup holds. A backup containing only docker.io/library/redis restores to harbor.local/myproject/library/redis, never to harbor.local/myproject.
  • Build each target reference as <target>/<source repository path>:<tag>. Don't normalize Docker Hub short names: library/ is kept.
  • Detect collisions before pushing: if two source repositories map to the same target (e.g. docker.io/library/nginx and mirror.gcr.io/library/nginx), fail with an error that lists every colliding pair, not just the first.
  • Validate every derived target repository name before pushing anything. Names come from data in the backup, which may not be trusted, so a bad entry must not leave a partial restore behind.
  • Add --preserve-source-registry to keep the source host as the first path component (harbor.local/myproject/docker.io/library/redis:7.2-alpine). It can't be combined with --rules. A source registry with a port (localhost:5000) can't be a path component; document this in the flag help and the error.
  • Report the mapping and any collisions in --dry-run.
  • Accept only <target-registry>[/<namespace>] as the target. Reject a tag or digest in it (e.g. harbor.local/myproject:v1) with a clear error, rather than treating it as a filter, which reads like a destination tag. Existing <repo>:v1,v2 command lines then fail visibly instead of restoring everything.
  • Tag-only backups from earlier versions have no repository path, so they keep restoring to the given argument as the target repository.
  • Create each target repository with opts.NewRepository, not Registry.Repository, so repository-level containers-config settings (policy, per-namespace registries.conf entries) still apply.
  • Unit and e2e tests. Besides updating the existing restore e2e cases to the nested paths, add e2e cases for a backup of several repositories restored to a bare registry, --preserve-source-registry, the collision error, and rejecting a tag in the target.

Not in scope

  • Selecting what to restore. This comes in a follow-up as repeatable --include [<registry>/]<repository>[:<tag>] patterns matched against the source references (Mode 2 in docs: record full references and support multiple registries in backup proposal #2358), so the target argument stays a destination only.
  • Renaming or remapping repositories on restore, e.g. restoring library/redis as redis. This can come later through Mode 3 (--rules).
  • Backing up from more than one registry. That needs an oras-go change and is tracked separately.

Breaking change

Today oras restore --input backup.tar harbor.local/myproject/redis pushes to harbor.local/myproject/redis. After this change the same command pushes to harbor.local/myproject/redis/library/redis. Specifying tags in the target (harbor.local/myproject/redis:v1,v2) is also no longer supported until --include lands. Backup/restore is experimental, so this is acceptable, but the release notes must call it out. The proposal (#2358) has been updated to match.

Refs #1917, #2358, #1904

Activity

  1. added
    enhancement
    experimental
    on Nov 25, 2026
  2. added
    help wanted
    on Nov 25, 2026
  3. Orion777-cmd commented on Nov 25, 2026

    @Orion777-cmd
    Contributor

    I'd like to work on this. I plan to implement Mode 1 ("Direct Restore") as described in the proposal in #2358 and open a draft PR early for feedback. Is it OK to start now, or would you prefer I wait until #2358 is agreed?

  4. added a commit that references this issue on Nov 27, 2026
    b7cd0b1
  5. TerryHowe commented on Nov 27, 2026

    @TerryHowe
    MemberAuthor

    Two updates since this was implemented in #2376, to match the proposal in #2358:

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

    enhancementexperimentalhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions