
如果你使用 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 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Docker镜像源代码:https://github.com/ngosang/restic-exporter
https://github.com/restic/restic%E5%A4%87%E4%BB%BD%E7%B3%BB%E7%BB%9F%E7%9A%84Prometheus%E5%AF%BC%E5%87%BA%E5%99%A8%E3%80%82
该镜像提供Restic备份系统的Prometheus指标导出功能,可监控Restic仓库的关键状态,如备份检查结果、快照数量、备份时间戳、文件总数、备份大小等。支持多种存储后端(本地、REST Server、Amazon S3、Backblaze B2等),适用于需要对Restic备份进行可视化监控和告警的场景。
restic check)该镜像支持以下架构:
镜像可从GHCR或DockerHub拉取:
bash# 从GHCR拉取 docker pull ***-ghcr.xuanyuan.run/ngosang/restic-exporter # 或从DockerHub拉取 docker pull docker.xuanyuan.run/ngosang/restic-exporter
兼容docker-compose v2架构:
yaml--- version: '2.1' services: restic-exporter: image: docker.xuanyuan.run/ngosang/restic-exporter container_name: restic-exporter environment: - TZ=Europe/Madrid # 时区 - RESTIC_REPOSITORY=/data # Restic仓库路径或URL - RESTIC_PASSWORD=<password_here> # 仓库密码(明文) # - RESTIC_PASSWORD_FILE=</file_with_password_here> # 密码文件路径(二选一) - REFRESH_INTERVAL=1800 # 指标刷新间隔(秒,默认60) volumes: - /host_path/restic/data:/data # 挂载本地仓库路径(如使用本地后端) ports: - "8001:8001" # 默认监听端口 restart: unless-stopped
bashdocker run -d \ --name=restic-exporter \ -e TZ=Europe/Madrid \ -e RESTIC_REPOSITORY=/data \ -e RESTIC_PASSWORD=<password_here> \ -e REFRESH_INTERVAL=1800 \ -p 8001:8001 \ --restart unless-stopped \ docker.xuanyuan.run/ngosang/restic-exporter
所有配置通过环境变量实现,支持Restic的https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html%EF%BC%8C%E9%83%A8%E5%88%86%E5%90%8E%E7%AB%AF%E9%9C%80%E9%A2%9D%E5%A4%96%E9%85%8D%E7%BD%AE%E5%AF%86%E9%92%A5%E3%80%82
| 变量名 | 说明 | 示例 |
|---|---|---|
RESTIC_REPOSITORY | Restic仓库URL,支持所有后端 | 本地:/data;S3:s3:s3.amazonaws.com/bucket_name;B2:b2:bucketname:path |
RESTIC_PASSWORD | 仓库密码(明文),与RESTIC_PASSWORD_FILE二选一 | mypassword123 |
RESTIC_PASSWORD_FILE | 密码文件路径(需挂载文件到容器内),与RESTIC_PASSWORD二选一 | /restic_password.txt |
REFRESH_INTERVAL | 指标刷新间隔(秒),默认60秒(建议设为较大值,如30分钟=1800秒) | 1800 |
LISTEN_PORT | 监听端口,默认8001 | 8080 |
LISTEN_ADDRESS | 监听地址,默认所有地址 | 127.0.0.1 |
LOG_LEVEL | 日志级别,默认INFO | DEBUG、WARNING、ERROR |
EXIT_ON_ERROR | 遇Restic错误时是否退出,默认False(仅日志记录) | True |
| 后端类型 | 所需环境变量 |
|---|---|
| Amazon S3/Minio/Wasabi | AWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEY |
| Backblaze B2 | B2_ACCOUNT_ID、B2_ACCOUNT_KEY |
Docker镜像不包含Rclone,若使用Rclone后端(rclone:remote:/path),需挂载主机的Rclone可执行文件和配置文件:
yamlversion: '2.1' services: restic-exporter: image: docker.xuanyuan.run/ngosang/restic-exporter container_name: restic-exporter environment: - TZ=Europe/Madrid - RESTIC_REPOSITORY=rclone:gd-backup:/restic # Rclone远程仓库 - RESTIC_PASSWORD=<password_here> - REFRESH_INTERVAL=1800 volumes: - /usr/bin/rclone:/usr/bin/rclone:ro # 挂载主机Rclone可执行文件 - /host_path/rclone.conf:/root/.config/rclone/rclone.conf:ro # 挂载Rclone配置文件 ports: - "8001:8001" restart: unless-stopped
| 指标名称 | 类型 | 说明 | 示例值 |
|---|---|---|---|
restic_check_success | gauge | restic check操作结果(1=成功,0=失败) | 1.0 |
restic_locks_total | counter | 仓库锁总数 | 1.0 |
restic_snapshots_total | counter | 快照总数 | 100.0 |
restic_backup_timestamp | gauge | 最后备份时间戳 | 1.666273638e+09(带标签:客户端主机名、用户名、快照哈希等) |
restic_backup_files_total | counter | 备份文件总数 | 8.0(带标签:同上) |
restic_backup_size_total | counter | 备份总大小(字节) | 4.3309562e+07(带标签:同上) |
restic_backup_snapshots_total | counter | 快照计数 | 1.0(带标签:同上) |
restic_scrape_duration_seconds | gauge | 指标采集耗时(秒) | 166.9411084651947 |
yamlscrape_configs: - job_name: 'restic-exporter' static_configs: - targets: ['192.168.1.100:8001'] # restic-exporter实例地址
yaml- alert: ResticCheckFailed expr: restic_check_success == 0 for: 5m labels: severity: critical annotations: summary: Restic检查失败(实例 {{ $labels.instance }}) description: Restic仓库检查失败\n VALUE = {{ $value }}\n LABELS = {{ $labels }} - alert: ResticOutdatedBackup expr: time() - restic_backup_timestamp > 1209600 # 15天(1209600秒) for: 0m labels: severity: critical annotations: summary: Restic {{ $labels.client_hostname }} / {{ $labels.client_username }} 备份过期 description: Restic备份已过期\n VALUE = {{ $value }}\n LABELS = {{ $labels }}
提供参考Grafana仪表盘:https://github.com/ngosang/restic-exporter/blob/main/grafana/grafana_dashboard.json?raw=true
!https://github.com/ngosang/restic-exporter/blob/main/grafana/grafana_dashboard.png?raw=true
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务