borgmatic + pushplus:备份结束推到微信
效果:borgmatic 跑完或失败时,微信收到备份结果,不用登录服务器翻日志。
borgmatic 内置 Apprise hooks。填 pushplus://你的token 即可。
前置条件
- 一个 pushplus token(官网扫码获取)
- 已能成功执行
borgmatic,可改配置文件(常见为/etc/borgmatic/config.yaml)
配置步骤
- 确认本机
borgmatic --version带 Apprise hooks(1.8+ 常见),并已安装apprise。 - 在配置里增加(键名以你的 borgmatic 版本文档为准,多在
hooks:下):
hooks:
apprise:
services:
- url: pushplus://你的token
label: pushplus
states:
- finish
- fail
一对多:pushplus://你的token/群组编码。borgmatic 给出的标题/正文会映射为 title / content。 3. 不要把 token 提交进公开仓库,可用环境变量替换 URL 中的 token。 4. 没有 Apprise hooks 时,用 after / on_error 命令:
hooks:
after:
- curl -s -X POST https://www.pushplus.plus/send -H "Content-Type: application/json" -d '{"token":"你的token","title":"borgmatic 备份结束","content":"请查看 borgmatic 日志","template":"markdown"}'
on_error:
- curl -s -X POST https://www.pushplus.plus/send -H "Content-Type: application/json" -d '{"token":"你的token","title":"borgmatic 备份失败","content":"请登录服务器查看日志","template":"markdown"}'
content 必填。完整字段见 消息接口。
验证
curl -X POST "https://www.pushplus.plus/send" \
-H "Content-Type: application/json" \
-d '{"token":"你的token","title":"borgmatic 配置测试","content":"token 可用","template":"markdown"}'
也可:apprise -t "测试" -b "测试" "pushplus://你的token",再跑一次 borgmatic --dry-run 或小仓库试备份。
常见问题
finish 有、fail 没有? 确认 states 含 fail,且失败发生在 hooks 已加载之后。网络与额度见 收不到消息、接口限制。
每天都推嫌吵? states 只留 fail。