ai_member_xiaoyan/scripts/backup_skills_to_github.sh

31 lines
1.0 KiB
Bash
Raw Permalink 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
# 技能备份到GitHub脚本
SKILLS_DIR="/root/.openclaw/workspace-xiaoyan/skills"
BACKUP_DIR="/tmp/skills_backup"
GIT_REPO="git@github.com:valalab/skills-backup.git" # 请替换为实际的GitHub仓库地址
LOG_FILE="/tmp/skill_backup.log"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 开始备份技能到GitHub..." > "$LOG_FILE"
# 复制技能文件到临时目录
rm -rf "$BACKUP_DIR"
mkdir -p "$BACKUP_DIR"
cp -r "$SKILLS_DIR"/* "$BACKUP_DIR"/
# 初始化git并推送
cd "$BACKUP_DIR" || exit 1
git init >> "$LOG_FILE" 2>&1
git config user.name "xiaoyan-bot" >> "$LOG_FILE" 2>&1
git config user.email "bot@vala.com" >> "$LOG_FILE" 2>&1
git add . >> "$LOG_FILE" 2>&1
git commit -m "Backup skills at $(date '+%Y-%m-%d %H:%M:%S')" >> "$LOG_FILE" 2>&1
git branch -M main >> "$LOG_FILE" 2>&1
git remote add origin "$GIT_REPO" >> "$LOG_FILE" 2>&1
git push -f origin main >> "$LOG_FILE" 2>&1
if [ $? -eq 0 ]; then
echo "备份成功" >> "$LOG_FILE"
else
echo "备份失败请检查GitHub仓库权限和地址配置" >> "$LOG_FILE"
fi