initial backup 2026-03-31 11:40:15

This commit is contained in:
ai@valavala.com 2026-03-31 11:40:15 +08:00
parent c8c3f2fb11
commit 7282c36cdc
3 changed files with 20 additions and 13 deletions

View File

@ -3,6 +3,7 @@
自动将OpenClaw workspace内容定期备份到Git仓库自动过滤敏感信息无硬编码凭证。
## 特性
- ✅ 全流程自动化无需手动提前创建Git仓库
- ✅ 支持多数字员工共用同一个Git账号按数字员工名称区分仓库
- ✅ 自动排除密钥、密码等敏感文件secrets.md、.env、*.key等
- ✅ 内置公司Git服务git.valavala.com支持无需额外配置地址
- ✅ 支持自定义定时备份时间
@ -20,10 +21,11 @@
## 配置参数
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| git_token | string | 是 | Git仓库访问Token |
| git_username | string | 是 | Git用户名 |
| agent_name | string | 是 | 数字员工唯一名称如xiaoyan/xiaoxi/xiaokui等用于生成唯一仓库名 |
| git_token | string | 是 | Git仓库访问Token所有数字员工共用同一个Git账号的Token |
| git_username | string | 是 | Git用户名所有数字员工共用同一个Git账号 |
| git_email | string | 是 | Git提交邮箱 |
| git_repo_url | string | 否 | Git仓库HTTPS地址格式https://域名/所有者/仓库名.git默认使用公司git.valavala.com服务自动生成仓库地址https://git.valavala.com/{git_username}/ai_member_{git_username}.git |
| git_repo_url | string | 否 | Git仓库HTTPS地址格式https://域名/所有者/仓库名.git默认使用公司git.valavala.com服务自动生成仓库地址https://git.valavala.com/{git_username}/ai_member_{agent_name}.git |
| cron_schedule | string | 否 | 定时任务cron表达式默认值`30 8 * * *`每天早上8:30 |
## 使用方法
### 1. 初始化配置

View File

@ -1,13 +1,14 @@
#!/bin/bash
set -e
# 从传入参数获取配置,无硬编码敏感信息
GIT_TOKEN="$1"
GIT_USERNAME="$2"
GIT_EMAIL="$3"
GIT_REPO_URL="${4:-https://git.valavala.com/${GIT_USERNAME}/ai_member_${GIT_USERNAME}.git}"
CRON_SCHEDULE="${5:-30 8 * * *}"
AGENT_NAME="$1"
GIT_TOKEN="$2"
GIT_USERNAME="$3"
GIT_EMAIL="$4"
GIT_REPO_URL="${5:-https://git.valavala.com/${GIT_USERNAME}/ai_member_${AGENT_NAME}.git}"
CRON_SCHEDULE="${6:-30 8 * * *}"
# 自动创建Git仓库如果不存在
REPO_NAME="ai_member_${GIT_USERNAME}"
REPO_NAME="ai_member_${AGENT_NAME}"
echo "🔍 检查Git仓库是否存在: $REPO_NAME"
REPO_CHECK=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GIT_TOKEN" "https://git.valavala.com/api/v1/repos/$GIT_USERNAME/$REPO_NAME")
if [ "$REPO_CHECK" -eq 404 ]; then
@ -18,7 +19,7 @@ if [ "$REPO_CHECK" -eq 404 ]; then
-d "{
\"name\": \"$REPO_NAME\",
\"private\": false,
\"description\": \"${GIT_USERNAME} workspace 备份\",
\"description\": \"${AGENT_NAME} workspace 备份\",
\"auto_init\": false
}")
if echo "$CREATE_RESPONSE" | grep -q '"id":'; then

View File

@ -3,12 +3,16 @@ description: 自动备份OpenClaw workspace到Git仓库支持定时任务
version: 1.0.0
author: xiaoyan
parameters:
agent_name:
description: 数字员工名称如xiaoyan/xiaoxi/xiaokui等用于生成仓库名
required: true
type: string
git_token:
description: Git仓库访问Token
description: Git仓库访问Token所有数字员工共用同一个Git账号的Token
required: true
type: string
git_username:
description: Git用户名
description: Git用户名所有数字员工共用同一个Git账号
required: true
type: string
git_email:
@ -16,7 +20,7 @@ parameters:
required: true
type: string
git_repo_url:
description: Git仓库HTTPS地址可选默认使用公司git.valavala.com服务仓库名规则ai_member_${git_username}
description: Git仓库HTTPS地址可选默认使用公司git.valavala.com服务仓库名规则ai_member_${agent_name}
required: false
type: string
cron_schedule: