ai_member_xiaobian/scripts/workspace_backup.sh
2026-04-04 21:46:39 +08:00

34 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Workspace自动备份脚本基于vala_git_workspace_backup.vala规范
WORKSPACE_DIR="/root/.openclaw/workspace-xiaobian"
cd "$WORKSPACE_DIR" || exit 1
# 配置远程仓库地址
git remote set-url origin https://ai_member_only:ai%40makee260301%23@git.valavala.com/ai_member_only/ai_member_xiaobian.git || true
# 拉取最新代码
git pull origin master || true
# 提交所有变更
git add .
git commit -m "auto backup $(date +'%Y-%m-%d %H:%M:%S')" || true
# 推送到远程仓库
git push origin master || true
# 备份成功后发送通知给李若松
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
# 获取飞书token
APP_ID=$(jq -r '.apps[0].appId' /root/.openclaw/credentials/xiaobian/config.json)
APP_SECRET=$(jq -r '.apps[0].appSecret' /root/.openclaw/credentials/xiaobian/config.json)
FEISHU_TOKEN=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d "{\"app_id\":\"$APP_ID\",\"app_secret\":\"$APP_SECRET\"}" | jq -r '.tenant_access_token')
# 发送消息
curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=user_id" \
-H "Authorization: Bearer $FEISHU_TOKEN" \
-H "Content-Type: application/json" \
-d '{"receive_id": "4aagb443", "msg_type": "text", "content": "{\"text\":\"✅ 小编Workspace自动备份成功备份时间'$(date +'%Y-%m-%d %H:%M:%S')'\"}"}' > /dev/null
fi
echo "✅ 备份完成:$(date)"