31 lines
1.0 KiB
Bash
31 lines
1.0 KiB
Bash
#!/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
|