ai_member_xiaoxi/daily_backup.sh
2026-03-11 09:04:52 +08:00

28 lines
1.1 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
set -e
# 进入工作区目录
cd /root/.openclaw/workspace
# 1. 确保敏感文件不会被提交到Git
if ! grep -q "secrets.md" .gitignore; then
echo "secrets.md" >> .gitignore
echo "*.env" >> .gitignore
echo "memory/*.private.md" >> .gitignore
fi
# 2. 提交所有变更
git add .
git commit -m "🤖 每日自动备份 - $(date +'%Y-%m-%d %H:%M:%S')" || echo "没有新的变更需要提交"
# 3. 推送到远程仓库
if git push; then
echo "Git推送成功 - $(date +'%Y-%m-%d %H:%M:%S')"
# 发送备份成功通知
/root/.nvm/versions/node/v24.14.0/bin/openclaw message send --channel feishu --target user:ou_9cb5bc9a5f1b6cab2d78fd36139ecb87 --text "✅ 每日工作区备份成功所有变更已同步到Git仓库备份时间$(date +'%Y-%m-%d %H:%M:%S')"
else
echo "Git推送失败 - $(date +'%Y-%m-%d %H:%M:%S')"
# 发送备份失败通知
/root/.nvm/versions/node/v24.14.0/bin/openclaw message send --channel feishu --target user:ou_9cb5bc9a5f1b6cab2d78fd36139ecb87 --text "❌ 每日工作区备份失败请检查Git仓库配置和网络连接错误时间$(date +'%Y-%m-%d %H:%M:%S')"
fi