Auto backup: 2026-02-17 18:00
This commit is contained in:
@@ -18,6 +18,21 @@ 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() {
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to backup a repo
|
||||
backup_repo() {
|
||||
local path=$1
|
||||
@@ -36,8 +51,7 @@ backup_repo() {
|
||||
echo "✅ $name: Backup successful" | tee -a "$LOG_FILE"
|
||||
else
|
||||
echo "❌ $name: Push failed - check credentials" | tee -a "$LOG_FILE"
|
||||
echo " To fix: git config --global credential.helper store" | tee -a "$LOG_FILE"
|
||||
echo " Then: cd $path && git push (enter credentials once)" | tee -a "$LOG_FILE"
|
||||
send_gotify "⚠️ Backup Failed" "$name push to Gitea failed. Check credentials." 5
|
||||
fi
|
||||
else
|
||||
echo "⏭️ $name: No changes to backup" | tee -a "$LOG_FILE"
|
||||
@@ -55,4 +69,7 @@ echo "📄 Log saved to: $LOG_FILE" | tee -a "$LOG_FILE"
|
||||
# Show recent backups
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
echo "📊 Recent backups:" | tee -a "$LOG_FILE"
|
||||
cd /home/openclaw/.openclaw/workspace && git log --oneline -3 | 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"
|
||||
Reference in New Issue
Block a user