Skip to content

docs: record full references and support multiple registries in backup proposal - #2358

Open
TerryHowe wants to merge 6 commits into
oras-project:mainfrom
TerryHowe:docs/backup-restore-multi-registry
Open

TerryHowe wants to merge 6 commits into
oras-project:mainfrom
TerryHowe:docs/backup-restore-multi-registry

Conversation

@TerryHowe

@TerryHowe TerryHowe commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Updates the multi-repository backup/restore proposal (#1917) in four ways.

1. Always record the full reference. org.opencontainers.image.ref.name always holds <registry>/<repository>:<tag>. The tag-only default and the --full-reference flag are removed, so there is one backup format. oras backup and oras restore are experimental, so the format changes without an opt-in flag. Restore still reads tag-only backups from earlier versions, but earlier clients cannot restore new backups. The Backward Compatibility section spells this out.

2. Allow backups from multiple registries. The same-registry restriction came from an oras-go limitation at the time, and it forced the air-gap scenario in #1893 into one archive per registry. The proposal now allows mixed-registry backups and restoring them to one registry, with these defaults:

  • No global registry flags: a single value can't say which registry it applies to, so backup and restore drop the credential, TLS, header and --distribution-spec flags, even when only one registry is involved. Credentials come from the credential store (oras login, --registry-config). TLS, plain HTTP and referrers settings come from registries.conf/certs.d. --registry-config and --resolve stay. Prerequisites (per-registry plain HTTP, and reading containers configuration without the experimental variable) and the implementation are tracked in [Draft] feat(backup,restore)!: remove global registry flags #2380.
  • Restore mapping: Mode 1 and Mode 2 drop the source registry host and keep the path. Mode 1 now accepts <registry>[/<namespace>], which the existing use cases already relied on.
  • Collisions: if two sources map to the same target (e.g. docker.io/library/nginx and mirror.gcr.io/library/nginx), restore fails before pushing anything. Dry-run reports collisions too.
  • --preserve-source-registry (new restore flag): keeps the source host as the first path component, e.g. airgap/docker.io/library/nginx. The host is lowercased and a port : becomes _ (registry.lan:5000 → registry.lan_5000) so the result is a valid repository name; IPv6 literal hosts and names over 255 characters fail before pushing. Cannot be combined with --rules.
  • Rules file: fails if two sources write the same tag to the same target repository. This also covers the existing consolidation example.

3. Always keep the repository path on restore. A single positional restore argument is always <registry>[/<namespace>], however many repositories the backup holds. A backup containing only docker.io/library/redis:7.2-alpine restored to harbor.local/myproject goes to harbor.local/myproject/library/redis:7.2-alpine, the same place it would go in a multi-repository backup. This changes existing restore command lines: oras restore --input backup.tar target.com/team/repo used to push to target.com/team/repo and now pushes to target.com/team/repo/team/repo. Tag-only backups from earlier versions record no repository path, so for them the argument is still the target repository. Renaming on restore is left to rules files (Mode 3) for now.

4. Select what to restore with --include, not the target argument. Mode 2 no longer takes a list of positional target repositories. Artifacts are selected with repeatable --include <pattern> flags that match the source reference ([<registry>/]<repository>[:<tag>], * wildcard), and the single positional argument is always the destination. A tag or digest on the target (e.g. target.com/repo:v1,v2) is rejected instead of being reinterpreted, so existing scripts fail visibly; use --include '*:v1' --include '*:v2'. Patterns that match nothing fail before anything is pushed, and --include cannot be combined with --rules. Patterns are split into repository and tag parts at the last : after the last / (so registry ports work), * stays within its part, and Docker Hub short names are not expanded. On tag-only backups from earlier versions, only * / *:<tag> patterns match.

Other changes:

  • Backward-compatibility wording now says existing backup command lines keep working unless they use a removed registry flag.
  • Restoring a tag-only backup from an earlier version to a bare registry is rejected, since there is no repository to place it in.
  • Dry-run runs every pre-push check: collisions, rules-file tag conflicts, invalid target names and unmatched patterns.
  • Use Cases 1 and 5 show the nested target paths that result from restoring under a namespace.
  • Notes that --oci-layout <path>:<tag> splits on the last : and cannot address a full reference; the docs now point to --oci-layout-path instead.
  • Replaces the oras-go dependency with [Draft] feat(backup,restore)!: remove global registry flags #2380: oras-go already resolves credentials per host, so the single-registry limit was only the CLI applying one set of registry flags to every reference.
  • Replaces the "one backup per registry" air-gap example with a single mixed-registry backup.
  • Fixes the Selective Tag Restoration example to use library/, matching Mode 2's path-preserving behavior.

Part 1 is already implemented: #1904 writes the full reference to ref.name, with no flag.

Which issue(s) this PR fixes:
Related to #1893

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test? N/A, docs only
  • Does this change require a documentation update? This is the documentation update
  • Does this introduce breaking changes that would require an announcement or bumping the major version? The backup format change and the new restore target interpretation need release-note callouts; experimental commands, so no major bump
  • Do all new files have an appropriate license header? N/A, no new files

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.70%. Comparing base (46eb58a) to head (d5323c7).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2358      +/-   ##
==========================================
+ Coverage   90.68%   90.70%   +0.01%     
==========================================
  Files         156      157       +1     
  Lines        6625     7111     +486     
==========================================
+ Hits         6008     6450     +442     
- Misses        362      384      +22     
- Partials      255      277      +22     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…rgument

Keep the restore target to <target-registry>[/<namespace>] only, and
reject a tag or digest in it, so a selector is never read as a
destination. Selective restore (Mode 2) uses repeatable --include
patterns matched against the source references in the backup.

Signed-off-by: Terry Howe <[email protected]>
A backup can read from several registries and a restore with a rules file can push to several, so a single --plain-http, --ca-file, credential or header flag cannot say which registry it applies to. Take all registry settings from per-registry configuration instead, list the replacement for each removed flag, and record the prerequisites: per-registry plain HTTP and reading containers configuration without the experimental variable.

Signed-off-by: Terry Howe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant