Auto backup: 2026-02-21 07:01

This commit is contained in:
Krilly
2026-02-21 07:01:51 +00:00
parent 8757148122
commit 17b5b82d99
2012 changed files with 352552 additions and 331 deletions

View File

@@ -18,19 +18,29 @@ if ! git config --global credential.helper &>/dev/null; then
echo " Run: git config --global credential.helper store" | tee -a "$LOG_FILE"
fi
# Gotify alert function
send_gotify() {
# ntfy alert function
send_ntfy() {
local title="$1"
local message="$2"
local priority="${3:-0}"
local gotify_url="${GOTIFY_URL:-http://runtipi.kangaroo-eel.ts.net:8129}"
local gotify_token="${GOTIFY_API_KEY}"
if [[ -n "$gotify_token" ]]; then
curl -s -X POST "$gotify_url/message?token=$gotify_token" \
-H "Content-Type: application/json" \
-d "{\"title\":\"$title\",\"message\":\"$message\",\"priority\":$priority}" > /dev/null 2>&1
local priority="${3:-4}"
local sound="${4:-default}"
[[ -z "${NTFY_URL:-}" ]] && return 0
[[ -z "${NTFY_TOPIC:-}" ]] && return 0
# Enforce minimum priority (default 4)
local minp="${NTFY_MIN_PRIORITY:-4}"
if [[ "$priority" =~ ^[0-9]+$ ]] && [[ "$minp" =~ ^[0-9]+$ ]]; then
if (( priority < minp )); then
priority="$minp"
fi
fi
curl -s -X POST "${NTFY_URL%/}/${NTFY_TOPIC}" \
-H "Title: $title" \
-H "Priority: $priority" \
-H "Sound: $sound" \
-d "$message" > /dev/null 2>&1 || true
}
# Snapshot critical OpenClaw state into workspace repo so updates/reinstalls are recoverable
@@ -86,7 +96,7 @@ backup_repo() {
echo "$name: Backup successful" | tee -a "$LOG_FILE"
else
echo "$name: Push failed - check credentials" | tee -a "$LOG_FILE"
send_gotify "⚠️ Backup Failed" "$name push to Gitea failed. Check credentials." 5
send_ntfy "⚠️ Backup Failed" "$name push to Gitea failed. Check credentials." 4 default
fi
else
echo "⏭️ $name: No changes to backup" | tee -a "$LOG_FILE"
@@ -108,4 +118,4 @@ echo "📊 Recent backups:" | tee -a "$LOG_FILE"
cd /home/openclaw/.openclaw/workspace && git log --oneline -3 | tee -a "$LOG_FILE"
# Send success notification
send_gotify "✅ Backup Complete" "OpenClaw backup to Gitea succeeded"
send_ntfy "✅ Backup Complete" "OpenClaw backup to Gitea succeeded" 4 default