Auto backup: 2026-02-20 13:01

This commit is contained in:
Krilly
2026-02-20 13:01:46 +00:00
parent fa9191136f
commit 6337dac343
24 changed files with 13594 additions and 149 deletions

View File

@@ -0,0 +1,29 @@
# Auto-Backup Verifier — Runbook
## Purpose
Verify daily that backup pushed to Gitea includes critical files.
## Import
1. Open n8n → Workflows → Import from file
2. Import `backup-verifier-workflow.json`
3. Configure credentials:
- HTTP Header Auth for Gitea API (Authorization: token <YOUR_GITEA_TOKEN>)
- Telegram credential named `Telegram account`
4. Set env var in n8n for Gotify:
- `GOTIFY_TOKEN=<your token>`
## What it checks
- AGENTS.md
- MEMORY.md
- TOOLS.md
- state-backup/openclaw.json
- state-backup/cron/jobs.json
- state-backup/devices/paired.json
## Alerts
- Success: Gotify priority 2
- Failure: Gotify priority 9 + Telegram alert
## Notes
- Schedule is 02:20 AWST by default (after backup)
- Keep workflow inactive until credentials are confirmed

View File

@@ -0,0 +1,169 @@
{
"name": "Auto-Backup Verifier",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "20 2 * * *"
}
]
},
"timezone": "Australia/Perth"
},
"id": "cron-trigger",
"name": "Daily 02:20 AWST",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [200, 300]
},
{
"parameters": {
"assignments": {
"assignments": [
{ "name": "repoOwner", "type": "string", "value": "Anthony" },
{ "name": "repoName", "type": "string", "value": "openclaw-backups" },
{ "name": "branch", "type": "string", "value": "main" },
{ "name": "requiredPaths", "type": "string", "value": "AGENTS.md,MEMORY.md,TOOLS.md,state-backup/openclaw.json,state-backup/cron/jobs.json,state-backup/devices/paired.json" }
]
}
},
"id": "set-context",
"name": "Set Context",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [420, 300]
},
{
"parameters": {
"url": "=http://gitea.kangaroo-eel.ts.net:3000/api/v1/repos/{{$json.repoOwner}}/{{$json.repoName}}/branches/{{$json.branch}}",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"options": { "timeout": 10000 }
},
"id": "get-branch",
"name": "Get Branch Head",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [660, 300],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 2000
},
{
"parameters": {
"url": "=http://gitea.kangaroo-eel.ts.net:3000/api/v1/repos/{{$node[\"Set Context\"].json.repoOwner}}/{{$node[\"Set Context\"].json.repoName}}/git/trees/{{$json.commit.id}}?recursive=1",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"options": { "timeout": 10000 }
},
"id": "get-tree",
"name": "Get Repo Tree",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [900, 300],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 2000
},
{
"parameters": {
"jsCode": "const required = $node['Set Context'].json.requiredPaths.split(',').map(s => s.trim());\nconst tree = $json.tree || [];\nconst existing = new Set(tree.map(t => t.path));\nconst missing = required.filter(p => !existing.has(p));\nreturn [{ json: {\n status: missing.length ? 'failed' : 'ok',\n missing,\n checked: required.length,\n headSha: ($node['Get Branch Head'].json.commit || {}).id || '',\n repo: `${$node['Set Context'].json.repoOwner}/${$node['Set Context'].json.repoName}`\n}}];"
},
"id": "validate",
"name": "Validate Required Files",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [1140, 300]
},
{
"parameters": {
"conditions": {
"string": [
{ "value1": "={{$json.status}}", "operation": "equals", "value2": "ok" }
]
}
},
"id": "if-ok",
"name": "Backup OK?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [1360, 300]
},
{
"parameters": {
"url": "=http://runtipi.kangaroo-eel.ts.net:8129/message?token={{$env.GOTIFY_TOKEN}}",
"sendBody": true,
"contentType": "json",
"bodyParameters": {
"parameters": [
{ "name": "title", "value": "✅ Backup Verified" },
{ "name": "message", "value": "={{`Repo ${$json.repo} verified. SHA: ${$json.headSha.slice(0,7)}. Checked ${$json.checked} required files.`}}" },
{ "name": "priority", "value": "2" }
]
},
"options": { "timeout": 10000 }
},
"id": "notify-ok",
"name": "Gotify Success",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1600, 200]
},
{
"parameters": {
"url": "=http://runtipi.kangaroo-eel.ts.net:8129/message?token={{$env.GOTIFY_TOKEN}}",
"sendBody": true,
"contentType": "json",
"bodyParameters": {
"parameters": [
{ "name": "title", "value": "🚨 Backup Verification Failed" },
{ "name": "message", "value": "={{`Repo ${$json.repo} failed verification. Missing: ${$json.missing.join(', ')}. SHA: ${$json.headSha.slice(0,7)}`}}" },
{ "name": "priority", "value": "9" }
]
},
"options": { "timeout": 10000 }
},
"id": "notify-fail-gotify",
"name": "Gotify Failure",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1600, 360]
},
{
"parameters": {
"chatId": "1793951355",
"text": "={{`🦀 Backup verifier failed\nRepo: ${$json.repo}\nMissing: ${$json.missing.join(', ')}\nSHA: ${$json.headSha.slice(0,7)}`}}",
"additionalFields": {}
},
"id": "notify-fail-telegram",
"name": "Telegram Failure",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [1810, 360],
"credentials": {
"telegramApi": {
"name": "Telegram account"
}
}
}
],
"connections": {
"Daily 02:20 AWST": { "main": [[{ "node": "Set Context", "type": "main", "index": 0 }]] },
"Set Context": { "main": [[{ "node": "Get Branch Head", "type": "main", "index": 0 }]] },
"Get Branch Head": { "main": [[{ "node": "Get Repo Tree", "type": "main", "index": 0 }]] },
"Get Repo Tree": { "main": [[{ "node": "Validate Required Files", "type": "main", "index": 0 }]] },
"Validate Required Files": { "main": [[{ "node": "Backup OK?", "type": "main", "index": 0 }]] },
"Backup OK?": {
"main": [
[{ "node": "Gotify Success", "type": "main", "index": 0 }],
[{ "node": "Gotify Failure", "type": "main", "index": 0 }]
]
},
"Gotify Failure": { "main": [[{ "node": "Telegram Failure", "type": "main", "index": 0 }]] }
},
"settings": { "executionOrder": "v1" },
"active": false
}

View File

@@ -0,0 +1,98 @@
{
"name": "Newsletter Compressor",
"nodes": [
{
"parameters": {
"rule": {"interval": [{"field": "cronExpression", "expression": "15 7 * * *"}]},
"timezone": "Australia/Perth"
},
"id": "cron",
"name": "Daily 07:15 AWST",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [220, 300]
},
{
"parameters": {
"httpMethod": "POST",
"path": "newsletter-compressor-run",
"responseMode": "onReceived",
"options": {}
},
"id": "webhook",
"name": "Webhook Execute (POST)",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [220, 460]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"name": "wakeText",
"type": "string",
"value": "Create a morning newsletter compressor briefing for Anthony. Collect latest unread/recent newsletter-style items (AI/news/tech), cluster into themes, and send a concise Telegram brief to telegram:1793951355 with: (1) Top 5 bullets, (2) Why it matters in one line each, (3) One recommended read. Keep it tight and useful. If nothing meaningful, send NO_REPLY."
}
]
}
},
"id": "set",
"name": "Set Prompt",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [470, 380]
},
{
"parameters": {
"url": "http://openclaw.kangaroo-eel.ts.net:18789/api/wake",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"contentType": "json",
"bodyParameters": {
"parameters": [
{"name": "text", "value": "={{$json.wakeText}}"},
{"name": "mode", "value": "now"}
]
},
"options": {"timeout": 15000}
},
"id": "wake",
"name": "Trigger OpenClaw Briefing",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [730, 380],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 2000
},
{
"parameters": {
"url": "http://runtipi.kangaroo-eel.ts.net:8129/message?token=AGKnHafW3FGzBlt",
"sendBody": true,
"contentType": "json",
"bodyParameters": {
"parameters": [
{"name": "title", "value": "📰 Newsletter Compressor Triggered"},
{"name": "message", "value": "Morning newsletter compression job was triggered via n8n."},
{"name": "priority", "value": "3"}
]
}
},
"id": "gotify",
"name": "Gotify Status",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [980, 380]
}
],
"connections": {
"Daily 07:15 AWST": {"main": [[{"node": "Set Prompt", "type": "main", "index": 0}]]},
"Webhook Execute (POST)": {"main": [[{"node": "Set Prompt", "type": "main", "index": 0}]]},
"Set Prompt": {"main": [[{"node": "Trigger OpenClaw Briefing", "type": "main", "index": 0}]]},
"Trigger OpenClaw Briefing": {"main": [[{"node": "Gotify Status", "type": "main", "index": 0}]]}
},
"settings": {"executionOrder": "v1"},
"active": false
}

View File

@@ -0,0 +1,142 @@
{
"name": "OpenClaw Drift Detector",
"nodes": [
{
"parameters": {
"rule": {"interval": [{"field": "cronExpression", "expression": "45 6 * * *"}]},
"timezone": "Australia/Perth"
},
"id": "cron",
"name": "Daily 06:45 AWST",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [220, 320]
},
{
"parameters": {
"assignments": {
"assignments": [
{"name": "repoOwner", "type": "string", "value": "Anthony"},
{"name": "repoName", "type": "string", "value": "openclaw-backups"},
{"name": "branch", "type": "string", "value": "main"}
]
}
},
"id": "set",
"name": "Set Repo Context",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [440, 320]
},
{
"parameters": {
"url": "=http://gitea.kangaroo-eel.ts.net:3000/api/v1/repos/{{$json.repoOwner}}/{{$json.repoName}}/commits?sha={{$json.branch}}&limit=2",
"options": {"timeout": 10000}
},
"id": "commits",
"name": "Get Last 2 Commits",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [680, 320],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1500
},
{
"parameters": {
"jsCode": "const commits = Array.isArray($json) ? $json : ($json.data || []);\nif (commits.length < 2) {\n return [{json:{status:'insufficient_history', message:'Not enough commits to compare'}}];\n}\nreturn [{json:{status:'ok', head: commits[0].sha, base: commits[1].sha, headMsg: commits[0].commit?.message || '', baseMsg: commits[1].commit?.message || ''}}];"
},
"id": "prep",
"name": "Prepare Compare SHAs",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [920, 320]
},
{
"parameters": {
"conditions": {"string": [{"value1": "={{$json.status}}", "operation": "equals", "value2": "ok"}]}
},
"id": "if-ready",
"name": "Ready to Compare?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [1140, 320]
},
{
"parameters": {
"url": "=http://gitea.kangaroo-eel.ts.net:3000/api/v1/repos/Anthony/openclaw-backups/compare/{{$json.base}}...{{$json.head}}",
"options": {"timeout": 10000}
},
"id": "compare",
"name": "Compare Commits",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1360, 260],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1500
},
{
"parameters": {
"jsCode": "const files = $json.files || [];\nconst watch = [\n 'state-backup/openclaw.json',\n 'state-backup/cron/jobs.json',\n 'state-backup/devices/paired.json',\n 'AGENTS.md','SOUL.md','USER.md','TOOLS.md','MEMORY.md','HEARTBEAT.md'\n];\nconst changed = files.map(f => f.filename).filter(f => watch.some(w => f===w));\nconst critical = changed.filter(f => f.startsWith('state-backup/'));\nreturn [{json:{drift: changed.length>0, changed, critical, changedCount: changed.length, criticalCount: critical.length}}];"
},
"id": "analyze",
"name": "Analyze Drift",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [1580, 260]
},
{
"parameters": {
"conditions": {"boolean": [{"value1": "={{$json.drift}}", "operation": "true"}]}
},
"id": "if-drift",
"name": "Drift Detected?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [1800, 260]
},
{
"parameters": {
"url": "http://runtipi.kangaroo-eel.ts.net:8129/message?token=AGKnHafW3FGzBlt",
"sendBody": true,
"contentType": "json",
"bodyParameters": {"parameters": [
{"name": "title", "value": "🦀 OpenClaw Drift Detected"},
{"name": "message", "value": "={{`Changed files: ${$json.changed.join(', ')}${$json.criticalCount>0 ? '\nCritical state changed.' : ''}`}}"},
{"name": "priority", "value": "={{$json.criticalCount>0 ? 9 : 6}}"}
]}
},
"id": "gotify",
"name": "Gotify Drift Alert",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [2020, 220]
},
{
"parameters": {
"chatId": "1793951355",
"text": "={{`🦀 OpenClaw drift detected\nChanged: ${$json.changed.join(', ')}${$json.criticalCount>0 ? '\n⚠ Critical state changed' : ''}`}}"
},
"id": "tg",
"name": "Telegram Drift Alert",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [2240, 220],
"credentials": {"telegramApi": {"name": "Telegram account"}}
}
],
"connections": {
"Daily 06:45 AWST": {"main": [[{"node": "Set Repo Context", "type": "main", "index": 0}]]},
"Set Repo Context": {"main": [[{"node": "Get Last 2 Commits", "type": "main", "index": 0}]]},
"Get Last 2 Commits": {"main": [[{"node": "Prepare Compare SHAs", "type": "main", "index": 0}]]},
"Prepare Compare SHAs": {"main": [[{"node": "Ready to Compare?", "type": "main", "index": 0}]]},
"Ready to Compare?": {"main": [[{"node": "Compare Commits", "type": "main", "index": 0}], []]},
"Compare Commits": {"main": [[{"node": "Analyze Drift", "type": "main", "index": 0}]]},
"Analyze Drift": {"main": [[{"node": "Drift Detected?", "type": "main", "index": 0}]]},
"Drift Detected?": {"main": [[{"node": "Gotify Drift Alert", "type": "main", "index": 0}], []]},
"Gotify Drift Alert": {"main": [[{"node": "Telegram Drift Alert", "type": "main", "index": 0}]]}
},
"settings": {"executionOrder": "v1"},
"active": false
}

View File

@@ -0,0 +1,106 @@
{
"name": "Weekend Planner 2.0 (HITL)",
"nodes": [
{
"parameters": {
"rule": {"interval": [{"field": "cronExpression", "expression": "0 16 * * 5"}]},
"timezone": "Australia/Perth"
},
"id": "cron",
"name": "Friday 4:00 PM AWST",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [220, 280]
},
{
"parameters": {
"httpMethod": "POST",
"path": "weekend-planner-2-run",
"responseMode": "onReceived",
"options": {}
},
"id": "webhook-run",
"name": "Webhook Execute (POST)",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [220, 430]
},
{
"parameters": {
"assignments": {
"assignments": [
{"name": "draftPrompt", "type": "string", "value": "Create a weekend plan draft for Anthony in Perth. Use: calendar items next 3 days, Perth weather, and practical recommendations. Output concise sections: Saturday, Sunday, Prep List, and one fun optional idea. Keep it useful and warm."},
{"name": "approvalHint", "type": "string", "value": "Reply APPROVE to send full plan, or REGEN to regenerate."}
]
}
},
"id": "set",
"name": "Set Planner Prompt",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [450, 350]
},
{
"parameters": {
"url": "http://openclaw.kangaroo-eel.ts.net:18789/api/wake",
"sendBody": true,
"contentType": "json",
"bodyParameters": {
"parameters": [
{"name": "text", "value": "={{$json.draftPrompt}}"},
{"name": "mode", "value": "now"}
]
},
"options": {"timeout": 15000}
},
"id": "wake-draft",
"name": "Generate Plan Draft",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [700, 350],
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 2000
},
{
"parameters": {
"url": "http://runtipi.kangaroo-eel.ts.net:8129/message?token=AGKnHafW3FGzBlt",
"sendBody": true,
"contentType": "json",
"bodyParameters": {
"parameters": [
{"name": "title", "value": "🗓️ Weekend Planner Draft Ready"},
{"name": "message", "value": "={{`Draft generated. ${$node['Set Planner Prompt'].json.approvalHint}`}}"},
{"name": "priority", "value": "5"}
]
}
},
"id": "gotify-draft",
"name": "Gotify Draft Ready",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [940, 350]
},
{
"parameters": {
"chatId": "1793951355",
"text": "🦀 Weekend Planner draft is ready. Reply here with APPROVE to send final plan, or REGEN to regenerate."
},
"id": "telegram-review",
"name": "Telegram Review Prompt",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [1160, 350],
"credentials": {"telegramApi": {"name": "Telegram account"}}
}
],
"connections": {
"Friday 4:00 PM AWST": {"main": [[{"node": "Set Planner Prompt", "type": "main", "index": 0}]]},
"Webhook Execute (POST)": {"main": [[{"node": "Set Planner Prompt", "type": "main", "index": 0}]]},
"Set Planner Prompt": {"main": [[{"node": "Generate Plan Draft", "type": "main", "index": 0}]]},
"Generate Plan Draft": {"main": [[{"node": "Gotify Draft Ready", "type": "main", "index": 0}]]},
"Gotify Draft Ready": {"main": [[{"node": "Telegram Review Prompt", "type": "main", "index": 0}]]}
},
"settings": {"executionOrder": "v1"},
"active": false
}