funmirror
Mirror every repo from one hosting platform's organization to another's, in parallel, skipping repos whose default branch hasn't changed since the last run. Supports GitHub, Gitee, GitLab and GitCode as either source or destination.
Powered by a Rust async engine (funmirror-core) and distributed across three channels:
- Native CLI binary (
funmirror) — single static binary, zero Python runtime required, installed viaapt/brew/cargo install/ GitHub Releases. - Python package (
pip install funmirror) — PyO3 + maturin extension module with zero runtime dependencies (Python API only; noconsole_scriptsentry point). - Rust library crate (
funmirror-core) — reusable async mirroring engine on crates.io.
Built for farfarfun-action/mirror-repo,
which is a thin wrapper around this tool's CLI. It reproduces the core
behavior of Yikun/hub-mirror-action
(clone from the source platform, force-push refs/remotes/origin/*:refs/heads/*
plus tags to the destination) without depending on that action, and adds three
things it doesn't have:
- Two-phase parallelism — a cheap, read-only detect phase (Tokio async
pool,
--detect-workers, defaultmax(workers*4, 16)) checks every repo's commit id concurrently at high fan-out; only repos that actually differ move on to the heavier sync phase (--workers, default 8), which can be kept much lower to avoid overwhelming a rate-limited destination. - Skip-if-unchanged — before cloning anything, the latest commit sha of the source and destination default branch is compared; if they already match, the repo is skipped entirely.
- Release mirroring (
--sync-releases) — releases and their attached files, not just git refs. Off by default; see below.
Architecture
action-daily triggers mirror-repo, which installs and calls this CLI.
The CLI dispatches a high-concurrency detect phase, then a low-concurrency
sync phase against the source/destination platform; the state file is read
and rewritten locally on every run, and persisting it across CI runs is the
caller's job (see "Incremental sync via a state file" below).
Install
Native CLI (zero Python dependencies)
# APT (after adding the farfarfun repo, see https://farfarfun.github.io/packages/funmirror/)
sudo apt install funmirror
# Homebrew
brew install farfarfun/packages/funmirror
# Cargo
cargo install funmirror
# Or download a prebuilt static binary / .deb directly from GitHub Releases:
# https://github.com/farfarfun/funmirror/releases
funmirrorinvokesgit(andsshwhen using deploy keys) as a subprocess, sogitshould be available onPATH.
Python library (zero runtime dependencies, Python API only)
pip install funmirror
The PyPI wheel intentionally ships only the Python API (no
funmirrorconsole script) so it never conflicts with system-installed CLI binaries.
Rust library crate
[dependencies]
funmirror-core = "0.1"
CLI Usage
funmirror mirror \
--src-platform github --dst-platform gitee \
--src-org my-org --dst-org my-org \
--dst-token "$GITEE_TOKEN" \
--dst-key-file ~/.ssh/gitee_deploy_key \
--src-token "$GITHUB_TOKEN" \
--repo-names repo-a,repo-b \
--workers 8
--src-platform/--dst-platform are one of github, gitee, gitlab,
gitcode. --src-key-file/--dst-key-file (SSH key for push) are only
required when the corresponding platform is gitee. --src-endpoint/
--dst-endpoint are only used for self-hosted GitLab instances.
--repo-names is optional; if omitted, every repo in --src-org is
mirrored (requires --src-token to list them).
Run funmirror --help or funmirror mirror --help for the complete command
reference.
Exit code is 1 if any repo failed to mirror; a one-line summary
(Mirrored X, skipped Y, failed Z (total N)) is printed and, if
GITHUB_STEP_SUMMARY is set, appended to it (and mirrored/skipped/
failed/total are written to GITHUB_OUTPUT when set).
Python API
import funmirror
cfg = funmirror.MirrorConfig(
src_platform="github",
dst_platform="gitee",
src_org="my-org",
dst_org="my-org",
src_token="ghp_...",
dst_token="gitee_...",
dst_key_file="~/.ssh/gitee_deploy_key",
repo_names=["repo-a", "repo-b"],
workers=8,
state_file=".mirror-state/gitee.json",
incremental=True,
sync_releases=True,
release_limit=5,
)
summary = funmirror.mirror_org(cfg)
print(summary.summary, summary.ok)
Also available: funmirror.sync_repo(...), funmirror.sync_releases(...),
funmirror.state_namespace(...), funmirror.load_state(...), and
funmirror.save_state(...).
How a single repo is mirrored
Mirroring happens in two phases, run as two separate concurrent pipelines:
- Detect (
--detect-workers, high concurrency): for every repo, look up the latest commit sha of the source default branch (in--incrementalmode) or of both the source and destination branch (in full-sync mode, see below). Decide whether the repo needs syncing. - Sync (
--workers, low concurrency): only for repos the detect phase flagged as differing — create the destination repo if it doesn't exist yet, thengit clonefrom the source andgit push(force by default)refs/remotes/origin/*:refs/heads/*plus tags to the destination, with retries.
Keeping these as separate worker pools lets detection run fast and wide (it's just read-only API calls) while the actual clone+push traffic against a rate-limited/WAF'd destination like Gitee stays throttled.
Incremental sync via a state file
--state-file PATH persists a JSON map across runs, namespaced by
<src-platform>/<src-org>::<dst-platform>/<dst-org> so multiple platform
pairs can safely share one file without their progress getting mixed up:
{
"github/my-org::gitee/my-org": {
"repo-a": {"src_sha": "abc123", "dst_sha": "abc123"}
}
}
--incremental and full sync (the default, no --incremental) query
different things during detection:
--incremental: only the source platform's commit sha is queried, for every repo. If it matches the state file'ssrc_sha, the repo is skipped without ever querying the destination platform. If it doesn't match (or there's no state entry yet), the repo goes straight to the sync phase — trusting that the destination was already in sync as of the last recordedsrc_sha, so there's no need to read it first either.- Full sync (no
--incremental): both the source and destination platform's commit shas are queried for every repo, ignoring the state file for the skip/sync decision entirely — only repos whose source and destination shas actually differ are synced. This is what self-heals any drift an incremental run might have left behind (e.g. someone pushing directly to the destination).
# hourly, cheap: only the src platform is queried; most repos short-circuit
# off local state without a single dst API call
funmirror mirror --src-platform github --dst-platform gitee \
--src-org my-org --dst-org my-org --dst-token "$GITEE_TOKEN" \
--dst-key-file ~/.ssh/gitee_deploy_key --state-file .mirror-state/gitee.json \
--incremental
# daily, thorough: queries both src and dst for every repo and ignores the
# state file for the decision, then rewrites the state file from the
# confirmed results
funmirror mirror --src-platform github --dst-platform gitee \
--src-org my-org --dst-org my-org --dst-token "$GITEE_TOKEN" \
--dst-key-file ~/.ssh/gitee_deploy_key --state-file .mirror-state/gitee.json \
--workers 2
A repo's state entry is only ever updated once its shas are confirmed
(either via a detect-phase match, or after a successful push) — a repo that
fails to sync leaves its previous state entry untouched, so it's retried for
real on the next run instead of being incorrectly marked up to date.
funmirror only reads/writes the file locally; persisting it across CI runs
(e.g. committing it back to a repo) is the caller's responsibility.
Mirroring releases
A git mirror copies refs. It does not copy releases, and it certainly
doesn't copy the binaries attached to them — which for a tool distributed as
a prebuilt binary is the only part users actually need. --sync-releases
adds a second pass, run strictly after the push (a release points at a
tag; creating one for a tag the destination has never heard of either fails
or invents one off the wrong commit):
funmirror mirror --src-platform github --dst-platform gitee \
--src-org my-org --dst-org my-org \
--src-token "$GITHUB_TOKEN" --dst-token "$GITEE_TOKEN" \
--dst-key-file ~/.ssh/gitee_deploy_key \
--repo-names my-tool \
--sync-releases --release-limit 5
Currently GitHub can be a release source and Gitee a release destination. Other combinations are rejected up front with one line, rather than failing identically once per repo.
What the pass does, per release, oldest first:
- Look the release up on the destination by tag; create it if missing. Drafts on the source are skipped — a draft isn't public there, so mirroring it would leak it.
- Diff the attachments by name. Upload the missing ones; re-upload one whose size disagrees (deleting the stale copy first — Gitee has no overwrite, you'd end up with two files of the same name). Leave the rest alone.
- Download and upload one asset at a time, deleting the local copy immediately, so peak disk is one asset rather than one release.
Two costs worth knowing before turning this on:
- Every selected repo gets a release listing on both sides, every run,
even the unchanged ones. Publishing a release moves a tag, not the
default branch — so a repo whose branch sha is identical can still be
missing its newest release. Skipping those on the sha alone would make
release mirroring miss exactly the case it exists for.
--sync-releasestherefore routes up-to-date repos into the sync phase too, where the clone+push is skipped and only the release diff runs. --release-limit Ncaps it to the N most recent releases per repo. Default0is all of them; on a repo with a long history and large binaries, the first run moves all of it.
Needs --dst-token (the SSH key only covers git, not the REST API) and a
--src-token for private sources. A repo with releases disabled reads as
"no releases" rather than an error. A release failure fails that repo and
leaves its state entry untouched, so the next run retries it.
Development
# Rust tests & lints
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace --exclude funmirror-py
# Build native CLI
cargo build --release --package funmirror
# Build and test Python extension
maturin build --release --out dist
pytest tests/test_funmirror.py
关于 farfarfun
farfarfun 是一个专注于实用工具库的开源组织, 涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
- 🏠 组织主页:https://github.com/farfarfun
- 📦 PyPI:https://pypi.org/user/niuliangtao/
- 📧 联系:farfarfun@qq.com
本项目基于 MIT 协议开源。
Metadata
Release files for funmirror 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| funmirror-0.7.0.tar.gz | 60.2 kB | Without provenance | Details for funmirror-0.7.0.tar.gz |
Built distributions (wheels)
Total release size: 13.6 MB
Release files / funmirror-0.7.0.tar.gz
| Download URL | funmirror-0.7.0.tar.gz |
|---|---|
| Size | 60.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef741f2e10e13c772076ee634b06b0784fcfbd51e23c14626412319ad3c3233a
|
|
BLAKE2b-256 checksum How to use checksums |
627918d6198ba141de6a863997b1cf491d795c537c189818686568bd454c8e59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / funmirror-0.7.0-cp312-abi3-win_amd64.whl
| Download URL | funmirror-0.7.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ba9283362bec25b5fc35405e13f0263845b447fa32a986a455ef87db3ee3ba44
|
|
BLAKE2b-256 checksum How to use checksums |
bf8281844f6a9c41e150e2ed556dc9ca47b15cf40d9edab0080096ab7122f314
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / funmirror-0.7.0-cp312-abi3-musllinux_1_2_x86_64.whl
| Download URL | funmirror-0.7.0-cp312-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ebd3eb44aab7effd31dff1c6ddee7a5ac1f985d1f2e78a7b03b3e964bd9a7d1e
|
|
BLAKE2b-256 checksum How to use checksums |
23aca2d027c94e890e4e721872dfeae891bf0430ed2391c405ad65de94a31142
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / funmirror-0.7.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | funmirror-0.7.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ac71fc09e942295a17879d4fec04144b0cf096da1800495f03ba5201d7e0a5dd
|
|
BLAKE2b-256 checksum How to use checksums |
4b457ff5da81f8bdb4f17bd7d4b6a24104827615942cf1922fd7345c986ed3e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / funmirror-0.7.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | funmirror-0.7.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f8eb1ab8cb74a42a99086237a5fd158de2ec8ce07840e889952762616ca84947
|
|
BLAKE2b-256 checksum How to use checksums |
6618966cbf10d2d00d634a7b7b5e93f00bb42e09f6957acedc04deeccb487f14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / funmirror-0.7.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | funmirror-0.7.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1b4de243767d5397659f8a85144a86a5d34246980a7db5357e69f6481202b2df
|
|
BLAKE2b-256 checksum How to use checksums |
8c8a0a683f57fadbc1fe21bc0b8e3e00a43439cbf5ecb438c616bf8c1daa711d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 / funmirror-0.7.0-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | funmirror-0.7.0-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
d6bd929ee753b0255670c5c59a04b7c6f3f5cbdd99bc89fb04fcdf12b6eaa09c
|
|
BLAKE2b-256 checksum How to use checksums |
44884906548eea776f096d403d8882fe285a7dc7cd044ac665091ba654cdc307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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}
|
Security for funmirror 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.