Repository navigation
Description
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/myprojectStored 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 onlydocker.io/library/redisrestores toharbor.local/myproject/library/redis, never toharbor.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/nginxandmirror.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-registryto 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,v2command 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, notRegistry.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/redisasredis. 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.
Activity
docs: always keep repository paths under the restore target
Orion777-cmd commentedon Nov 25, 2026
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?
feat(restore)!: restore multi-repository backups to <registry>[/<name…
TerryHowe commentedon Nov 27, 2026
Two updates since this was implemented in #2376, to match the proposal in #2358:
--preserve-source-registry: rather than rejecting source registries with a port, the proposal now lowercases the host and replaces the port:with_(registry.lan:5000→registry.lan_5000); IPv6 literal hosts are still rejected. Tracked in feat(restore): encode source registry hosts with ports for --preserve-source-registry #2398.