initial backup 2026-03-31 11:40:15
This commit is contained in:
parent
c8c3f2fb11
commit
7282c36cdc
@ -3,6 +3,7 @@
|
|||||||
自动将OpenClaw workspace内容定期备份到Git仓库,自动过滤敏感信息,无硬编码凭证。
|
自动将OpenClaw workspace内容定期备份到Git仓库,自动过滤敏感信息,无硬编码凭证。
|
||||||
## 特性
|
## 特性
|
||||||
- ✅ 全流程自动化,无需手动提前创建Git仓库
|
- ✅ 全流程自动化,无需手动提前创建Git仓库
|
||||||
|
- ✅ 支持多数字员工共用同一个Git账号,按数字员工名称区分仓库
|
||||||
- ✅ 自动排除密钥、密码等敏感文件(secrets.md、.env、*.key等)
|
- ✅ 自动排除密钥、密码等敏感文件(secrets.md、.env、*.key等)
|
||||||
- ✅ 内置公司Git服务(git.valavala.com)支持,无需额外配置地址
|
- ✅ 内置公司Git服务(git.valavala.com)支持,无需额外配置地址
|
||||||
- ✅ 支持自定义定时备份时间
|
- ✅ 支持自定义定时备份时间
|
||||||
@ -20,10 +21,11 @@
|
|||||||
## 配置参数
|
## 配置参数
|
||||||
| 参数名 | 类型 | 必填 | 说明 |
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|--------|------|------|------|
|
|--------|------|------|------|
|
||||||
| git_token | string | 是 | Git仓库访问Token |
|
| agent_name | string | 是 | 数字员工唯一名称(如xiaoyan/xiaoxi/xiaokui等),用于生成唯一仓库名 |
|
||||||
| git_username | string | 是 | Git用户名 |
|
| git_token | string | 是 | Git仓库访问Token(所有数字员工共用同一个Git账号的Token) |
|
||||||
|
| git_username | string | 是 | Git用户名(所有数字员工共用同一个Git账号) |
|
||||||
| git_email | string | 是 | 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) |
|
| cron_schedule | string | 否 | 定时任务cron表达式,默认值:`30 8 * * *`(每天早上8:30) |
|
||||||
## 使用方法
|
## 使用方法
|
||||||
### 1. 初始化配置
|
### 1. 初始化配置
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
# 从传入参数获取配置,无硬编码敏感信息
|
# 从传入参数获取配置,无硬编码敏感信息
|
||||||
GIT_TOKEN="$1"
|
AGENT_NAME="$1"
|
||||||
GIT_USERNAME="$2"
|
GIT_TOKEN="$2"
|
||||||
GIT_EMAIL="$3"
|
GIT_USERNAME="$3"
|
||||||
GIT_REPO_URL="${4:-https://git.valavala.com/${GIT_USERNAME}/ai_member_${GIT_USERNAME}.git}"
|
GIT_EMAIL="$4"
|
||||||
CRON_SCHEDULE="${5:-30 8 * * *}"
|
GIT_REPO_URL="${5:-https://git.valavala.com/${GIT_USERNAME}/ai_member_${AGENT_NAME}.git}"
|
||||||
|
CRON_SCHEDULE="${6:-30 8 * * *}"
|
||||||
# 自动创建Git仓库(如果不存在)
|
# 自动创建Git仓库(如果不存在)
|
||||||
REPO_NAME="ai_member_${GIT_USERNAME}"
|
REPO_NAME="ai_member_${AGENT_NAME}"
|
||||||
echo "🔍 检查Git仓库是否存在: $REPO_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")
|
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
|
if [ "$REPO_CHECK" -eq 404 ]; then
|
||||||
@ -18,7 +19,7 @@ if [ "$REPO_CHECK" -eq 404 ]; then
|
|||||||
-d "{
|
-d "{
|
||||||
\"name\": \"$REPO_NAME\",
|
\"name\": \"$REPO_NAME\",
|
||||||
\"private\": false,
|
\"private\": false,
|
||||||
\"description\": \"${GIT_USERNAME} workspace 备份\",
|
\"description\": \"${AGENT_NAME} workspace 备份\",
|
||||||
\"auto_init\": false
|
\"auto_init\": false
|
||||||
}")
|
}")
|
||||||
if echo "$CREATE_RESPONSE" | grep -q '"id":'; then
|
if echo "$CREATE_RESPONSE" | grep -q '"id":'; then
|
||||||
|
|||||||
@ -3,12 +3,16 @@ description: 自动备份OpenClaw workspace到Git仓库,支持定时任务,
|
|||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
author: xiaoyan
|
author: xiaoyan
|
||||||
parameters:
|
parameters:
|
||||||
|
agent_name:
|
||||||
|
description: 数字员工名称(如xiaoyan/xiaoxi/xiaokui等),用于生成仓库名
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
git_token:
|
git_token:
|
||||||
description: Git仓库访问Token
|
description: Git仓库访问Token(所有数字员工共用同一个Git账号的Token)
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
git_username:
|
git_username:
|
||||||
description: Git用户名
|
description: Git用户名(所有数字员工共用同一个Git账号)
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
git_email:
|
git_email:
|
||||||
@ -16,7 +20,7 @@ parameters:
|
|||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
git_repo_url:
|
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
|
required: false
|
||||||
type: string
|
type: string
|
||||||
cron_schedule:
|
cron_schedule:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user