
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Containerized mbsync (isync) that mirrors a
list of IMAP accounts — defined in a .env file — into local Maildir
backups, and can restore those backups to a new IMAP server.
amd64 + arm64).SYNC_INTERVAL.<backup>/<account>/, restorable and greppable.📖 Full documentation & source: https://github.com/Josiah-OGT/imap-backup
latest, vX.Y.Z (releases), isync-<version> (e.g. isync-1.5.1),
sha-<short>, and a YYYYMMDD date tag on the weekly build. Pin a vX.Y.Z or
isync-<version> tag for reproducibility; use latest for the freshest isync.
shdocker pull unsalted1832/imap-backup:latest
1. Create docker-compose.yml:
yamlservices: imap-backup: image: unsalted1832/imap-backup:latest container_name: imap-backup env_file: .env restart: unless-stopped volumes: - ./backups:/backups - ./logs:/logs
2. Create .env with your accounts (numbered blocks; gaps are fine):
sh# Global (all optional — defaults shown) SYNC_INTERVAL=1h RETAIN_DELETED=false # false = exact mirror; true = keep server-deleted mail LOG_LEVEL=normal # normal | verbose | debug # Account 1 (minimum: HOST, USER, PASS) ACCOUNT_1_HOST=imap.gmail.com ACCOUNT_1_USER=alice@gmail.com ACCOUNT_1_PASS=app-password-here # ACCOUNT_1_PORT=993 # optional (default 993) # ACCOUNT_1_TLS=IMAPS # IMAPS (default) or STARTTLS (+ PORT=143)
For Gmail/Outlook use an app password, not your login password. To avoid plaintext, use
ACCOUNT_N_PASSCMD(any command that prints the password).
3. Start the backup service:
shmkdir -p backups logs docker compose up -d docker compose logs -f # live; also written to ./logs/imap-backup.log
The running backup service is left untouched:
shdocker compose run --rm imap-backup sync-once # a single backup cycle docker compose run --rm imap-backup restore # restore all accounts docker compose run --rm imap-backup restore 1 3 # restore specific indices
shdocker compose down # stop & remove the container docker compose pull && docker compose up -d # update to the latest image
docker run)shdocker run -d --name imap-backup --env-file .env \ -v ./backups:/backups -v ./logs:/logs \ unsalted1832/imap-backup:latest
Run a single cycle instead of the loop:
shdocker run --rm --env-file .env \ -v ./backups:/backups -v ./logs:/logs \ unsalted1832/imap-backup:latest sync-once
Set the restore target per account in .env (omit any field to fall back to the
original source value):
shACCOUNT_1_RESTORE_HOST=imap.newserver.com ACCOUNT_1_RESTORE_USER=alice@newserver.com ACCOUNT_1_RESTORE_PASS=new-password # optional: RESTORE_PRESYNC=true -> pull latest from source before pushing
Then run a one-off restore (restore pushes the local Maildir to the target):
shdocker compose run --rm imap-backup restore # all accounts docker compose run --rm imap-backup restore 1 # specific account(s)
The service container reports healthy while backup cycles keep completing,
and unhealthy when the loop stalls (no cycle activity for SYNC_INTERVAL +
HEALTH_GRACE) or HEALTH_MAX_FAILURES consecutive cycles fail. A cycle still
in progress counts as healthy, and one-off sync-once / restore runs always
report healthy.
shdocker ps # STATUS shows (healthy) / (unhealthy) docker inspect --format '{{.State.Health.Status}}' imap-backup
The failure reason (stale loop vs. failed cycles) is recorded in the
docker inspect health log.
| Variable | Default | Meaning |
|---|---|---|
SYNC_INTERVAL | 1h | Time between cycles (30, 30m, 1h, 1d). |
RETAIN_DELETED | false | false exact mirror (propagate server deletions); true archival (keep server-deleted mail). |
RESTORE_PRESYNC | false | Pull latest from source before a restore. |
HEALTH_GRACE | 5m | Slack beyond SYNC_INTERVAL before the loop counts as stale (unhealthy). |
HEALTH_MAX_FAILURES | 3 | Consecutive failed cycles before reporting unhealthy. |
LOG_LEVEL | normal | mbsync verbosity: normal (summary), verbose (-V), debug (-V -D). |
LOG_DIR | /logs | Logfile directory (mount it). |
LOG_MAX_SIZE | 10M | Rotate after this size. |
LOG_KEEP | 7 | Rotated logs retained. |
LOG_TIMESTAMPS | true | ISO timestamps on log lines. |
LOG_COMPRESS | false | gzip rotated logs. |
BACKUP_DIR | /backups | Maildir root (mount it). |
ACCOUNT_N_HOST / _USER / _PASS | — | Required per account. |
ACCOUNT_N_PORT / _TLS / _NAME / _PASSCMD | 993 / IMAPS / address / — | Optional. |
ACCOUNT_N_RESTORE_HOST/_PORT/_USER/_PASS/_TLS/_PASSCMD | source values | Restore target. |
root. PUID/PGID are not app settings — to own the
files as yourself, add a user: line to the service and feed it your host IDs:
then setyamluser: "${PUID:-0}:${PGID:-0}" # add under the imap-backup service
PUID/PGID (from id -u / id -g) in .env, or inline:
PUID=$(id -u) PGID=$(id -g) docker compose up -d. Pre-create backups/ and
logs/ as that user first. (With docker run, use --user "$(id -u):$(id -g)".):Z to the volume mounts, e.g.
./backups:/backups:Z.docker stop sends SIGTERM; the container finishes the
in-progress account, then exits.ACCOUNT_N_TLS=STARTTLS (+ ACCOUNT_N_PORT=143) for STARTTLS servers.Licensed under the terms in the https://github.com/Josiah-OGT/imap-backup.
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务