Skip to main content

model-mirror

Mirror Hugging Face repositories into local bulk storage, pin them to exact commits, and verify that their files remain complete.

model-mirror streams payload directly into one archive directory instead of leaving model-sized files in the default Hugging Face cache. It records the resolved Hub commit, local SHA-256 and Git blob hashes, the expected file list, and verification state beside each mirror.

If upstream later moves, disappears, or serves changed content, the existing local mirror is not silently updated.

Quick Start

Install the model-mirror-cli distribution from PyPI with uv using Python 3.11 or newer:

uv tool install model-mirror-cli

model-mirror config directory /mnt/big-drive/huggingface
model-mirror mirror org/model
model-mirror status

If Hugging Face token autodetection does not find the intended token:

model-mirror config set token-path ~/.cache/huggingface/token

For HDD-backed archives, sequential Xet reconstruction is usually preferable:

model-mirror config set hf-xet-reconstruct-write-sequentially true

The distribution is named model-mirror-cli to distinguish it from an unrelated package; the installed command remains model-mirror.

The Safety Model

  • Requested branches and tags resolve to concrete Hub commits before download.
  • Mirror, verification, and repair stay pinned to that recorded commit.
  • Downloads stream into resumable .incomplete files while hashes accumulate.
  • Completed files are verified and atomically renamed into place.
  • repair restores the recorded commit; it never applies a newer commit.
  • Upstream updates require an explicit, inspectable repair --update.
  • If upstream disappears, local verification and torrent recovery remain available.

Model formats are opaque bytes. Model-mirror does not impose assumptions about Safetensors, GGUF, ONNX, config.json, or framework-specific layouts.

Everyday Workflow

Mirror and verify:

model-mirror mirror org/model
model-mirror verify org/model
model-mirror repair org/model  # only if verification reports repair paths

mirror verifies by default. Full verification reports file count, payload size, bytes hashed, duration, and interactive progress. Cached verification can avoid rereading payload:

model-mirror verify --cached org/model
model-mirror verify --progress org/model

Archive status is metadata-only and normally returns quickly, even for large HDD mirrors:

model-mirror status
model-mirror status org/model
model-mirror status --check-upstream org/model
model-mirror status --json

--check-upstream is advisory and does not update local metadata.

When verification detects that upstream moved, preview the exact transition before applying it:

model-mirror diff org/model
model-mirror diff --verbose org/model
model-mirror diff --json org/model
model-mirror repair --update org/model

The preview shows commits, added, changed, removed, and reusable files, payload size changes, candidate downloads, and removal percentages.

For periodic archive maintenance:

model-mirror verify --all --max-age 30d || true
model-mirror repair --all

Do not join those commands with &&: verification exits non-zero when it finds repairable damage.

Experimental Torrent Recovery

Torrent support is optional and experimental:

uv tool install --force 'model-mirror-cli[torrent]'

Publish one immutable repo@resolved-commit, or recover it elsewhere:

model-mirror torrent publish org/model
model-mirror torrent serve

model-mirror torrent join /path/model@commit.torrent
model-mirror torrent join 'magnet:?xt=...' --seed

Publications are deterministic hybrid v1/v2 torrents. Managed seed intent survives restart, standard torrent clients can use the emitted artifacts, and native join finalizes a normal model-mirror archive without a second complete payload copy.

An active publication prevents the canonical mirror from moving to another commit until it is explicitly retired. Torrent consistency and upstream authenticity are recorded separately.

See the torrent guide for publication, managed seeding, external-client handoff, import, trust, repair, and retirement.

Removal And Interrupted Work

Remove a mirror through the resumable, confirmed lifecycle:

model-mirror remove org/model

remove displays the repository, commit, verification age, file count, and size before confirmation. Active torrent publications must be retired first.

Successful downloads leave no runtime cache in steady state. status reports identified interrupted staging with exact resume and cleanup commands. Inspect or remove disposable runtime cache explicitly:

model-mirror clean-cache
model-mirror clean-cache --force

Kernel-backed repository locks are released when a process or host exits; a leftover .verification.lock file alone does not indicate active work.

Command Map

model-mirror mirror org/model
model-mirror verify org/model
model-mirror verify --cached org/model
model-mirror repair org/model
model-mirror diff org/model
model-mirror status
model-mirror status --json
model-mirror offline org/model
model-mirror online org/model
model-mirror remove org/model
model-mirror clean-cache
model-mirror torrent publish org/model
model-mirror torrent join FILE_OR_MAGNET
model-mirror version

Omitting --repo-type uses the configured default, initially model. Dataset and Space repositories use --repo-type dataset or --repo-type space.

Run model-mirror --help, model-mirror COMMAND --help, or model-mirror config options for the authoritative CLI reference and exit status behavior.

Documentation

Installation Updates

uv tool upgrade model-mirror-cli
model-mirror --version
model-mirror version

--version is offline. version checks PyPI and prints all missed release notes plus the update command when the installation is out of date.

For development:

git clone https://github.com/xlr8harder/model-mirror.git
cd model-mirror
uv sync --locked --all-extras --dev
uv run coverage run -m pytest -q
uv run coverage report -m

Contributor and implementation details are in CONTRIBUTING.md. Model-mirror is licensed under the MIT License.

Metadata

Release files for model-mirror-cli 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for model-mirror-cli 0.3.2
File Size Uploaded
model_mirror_cli-0.3.2.tar.gz 193.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for model-mirror-cli 0.3.2
File Interpreter ABI Platform
model_mirror_cli-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 282.0 kB

Release files / model_mirror_cli-0.3.2.tar.gz

Download URL model_mirror_cli-0.3.2.tar.gz
Size 193.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0635b605fbd985d9b0a0b411359585552451cf67819b02a537bc58f220ee9c17
BLAKE2b-256 checksum
How to use checksums
a256eb2de99d0df6b81270d2bf54b415a3cb6e2a2e7422e7d07f433b9f032544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / model_mirror_cli-0.3.2-py3-none-any.whl

Download URL model_mirror_cli-0.3.2-py3-none-any.whl
Size 88.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a253050d1eda101c762dd8a44920f5bdc94a84b06173c9e8483a76585922467
BLAKE2b-256 checksum
How to use checksums
eeb5b8ed70cc43d7ba425bbaf013f362c3db7a454fdc7edd259801765cf06fd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page