Files
syncbot/config.example.toml
T
iceBear67 a006483bbc
ci / test (push) Canceled after 0s
docker / build (push) Canceled after 0s
init
2026-08-14 07:13:22 +00:00

107 lines
3.7 KiB
TOML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# syncbot 配置示例
#
# 所有字段都有默认值,最小可用配置只需要一个 [[repo]] 块和 src/dst 两个地址。
# 修改本文件后无需重启:syncbot 会在几秒内自动应用(详见 README 的「热更新」)。
[global]
# 本地镜像仓库和 SSH 状态的存放位置,需要可写并建议持久化。
work_dir = "/var/lib/syncbot"
# 所有仓库的默认轮询间隔,可被单个 [[repo]] 覆盖。
interval = "5m"
# 单次同步(fetch + push)的超时时间。大仓库首次克隆可能较久。
timeout = "30m"
# 同时进行的 git 进程数上限。这是内存占用的主要控制项:
# 每个并发任务约等于一个 git 进程的峰值内存。
concurrency = 2
# 连续失败后的退避上限,避免上游长时间挂掉时刷屏。
max_backoff = "1h"
# 日志:level = debug|info|warn|errorformat = text|json
log_level = "info"
log_format = "text"
# 可选的 HTTP 端点:/healthz /readyz /status /metrics
# 留空(或删掉本行)则完全不监听端口。
listen = ":8080"
# 多久检查一次本文件是否变化。
reload_interval = "5s"
# 下面这些是所有仓库的默认值,同样可以在 [[repo]] 里逐个覆盖。
# refs = ["refs/heads/*", "refs/tags/*"] # 镜像哪些引用
# prune = true # src 上删掉的分支/标签,也在 dst 上删掉
# force = true # 允许非快进推送(上游 rebase 后必须)
# atomic = false # true 表示所有引用要么全部更新、要么全不更新
# allow_empty = false # 允许「空的 src 清空 dst」,默认拒绝,见 README
# ssh_key = "/etc/syncbot/keys/id_ed25519"
# known_hosts = "/etc/syncbot/known_hosts"
# --- 典型场景:内网 GitLab -> GitHub,用 deploy key 推送 -------------------
[[repo]]
name = "my-project"
src = "https://gitlab.internal/team/my-project.git"
dst = "git@github.com:me/my-project.git"
interval = "1m"
# GitHub 分配给这个 bot 的 deploy key(需要勾选 "Allow write access")。
# 只读挂载、权限是 0644 也没关系,syncbot 会自动做一份 0600 的私有副本。
ssh_key = "/etc/syncbot/keys/my-project"
# --- src 需要 token 的场景 -------------------------------------------------
# URL 里的 ${VAR} 会用环境变量展开;变量未定义时启动直接报错,不会静默变成空串。
# 注意只支持 ${VAR} 这种写法,裸写的 $VAR 会原样保留(密码里常有 $)。
[[repo]]
name = "private-upstream"
src = "https://x-access-token:${SRC_TOKEN}@github.com/upstream/repo.git"
dst = "git@github.com:me/repo-mirror.git"
# 只镜像分支,不同步标签。
refs = ["refs/heads/*"]
# --- src 和 dst 各自使用不同凭据 -------------------------------------------
[[repo]]
name = "cross-host"
interval = "10m"
[repo.src]
url = "git@gitlab.internal:team/repo.git"
ssh_key = "/etc/syncbot/keys/gitlab"
known_hosts = "/etc/syncbot/known_hosts"
strict_host_key = "yes" # yes | no | accept-new
[repo.dst]
url = "git@github.com:me/repo.git"
ssh_key = "/etc/syncbot/keys/github"
# --- 暂时停掉某个仓库,不用删配置 ------------------------------------------
[[repo]]
name = "paused"
enabled = false
src = "https://example.com/paused.git"
dst = "git@github.com:me/paused.git"
# --- 超大仓库:限制 git 自身的内存占用 --------------------------------------
[[repo]]
name = "huge-monorepo"
src = "https://git.internal/huge.git"
dst = "git@github.com:me/huge.git"
interval = "30m"
timeout = "2h"
# 原样传给 git 的 -c 参数,用于压住打包时的内存峰值。
git_config = [
"pack.threads=1",
"pack.windowMemory=64m",
"core.bigFileThreshold=8m",
]