Initial commit with translated description
This commit is contained in:
68
SKILL.md
Normal file
68
SKILL.md
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
---
|
||||||
|
name: openclaw-backup
|
||||||
|
description: "备份和恢复OpenClaw数据。在用户要求创建备份、设置自动备份计划、从备份恢复或管理备份轮换时使用。处理~/.openclaw目录归档,并进行适当的排除。"
|
||||||
|
---
|
||||||
|
|
||||||
|
# OpenClaw Backup
|
||||||
|
|
||||||
|
Backup and restore OpenClaw configuration, credentials, and workspace.
|
||||||
|
|
||||||
|
## Create Backup
|
||||||
|
|
||||||
|
Run the backup script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/backup.sh [backup_dir]
|
||||||
|
```
|
||||||
|
|
||||||
|
Default backup location: `~/openclaw-backups/`
|
||||||
|
|
||||||
|
Output: `openclaw-YYYY-MM-DD_HHMM.tar.gz`
|
||||||
|
|
||||||
|
## What Gets Backed Up
|
||||||
|
|
||||||
|
- `openclaw.json` — main config
|
||||||
|
- `credentials/` — API keys, tokens
|
||||||
|
- `agents/` — agent configs, auth profiles
|
||||||
|
- `workspace/` — memory, SOUL.md, user files
|
||||||
|
- `telegram/` — session data
|
||||||
|
- `cron/` — scheduled tasks
|
||||||
|
|
||||||
|
## Excluded
|
||||||
|
|
||||||
|
- `completions/` — cache, regenerated automatically
|
||||||
|
- `*.log` — logs
|
||||||
|
|
||||||
|
## Setup Daily Backup with Cron
|
||||||
|
|
||||||
|
Use OpenClaw cron for daily backups with notification:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "daily-backup",
|
||||||
|
"schedule": {"kind": "cron", "expr": "0 3 * * *", "tz": "UTC"},
|
||||||
|
"payload": {
|
||||||
|
"kind": "agentTurn",
|
||||||
|
"message": "Run ~/.openclaw/backup.sh and report result to user."
|
||||||
|
},
|
||||||
|
"sessionTarget": "isolated",
|
||||||
|
"delivery": {"mode": "announce"}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Restore
|
||||||
|
|
||||||
|
See [references/restore.md](references/restore.md) for step-by-step restore instructions.
|
||||||
|
|
||||||
|
Quick restore:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
openclaw gateway stop
|
||||||
|
mv ~/.openclaw ~/.openclaw-old
|
||||||
|
tar -xzf ~/openclaw-backups/openclaw-YYYY-MM-DD_HHMM.tar.gz -C ~
|
||||||
|
openclaw gateway start
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rotation
|
||||||
|
|
||||||
|
Script keeps last 7 backups automatically.
|
||||||
6
_meta.json
Normal file
6
_meta.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"ownerId": "kn767bpva5fcrrd9hhxcjnfnns80pzhp",
|
||||||
|
"slug": "openclaw-backup",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"publishedAt": 1770475997563
|
||||||
|
}
|
||||||
46
references/restore.md
Normal file
46
references/restore.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Restore OpenClaw from Backup
|
||||||
|
|
||||||
|
## Quick Restore
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Stop OpenClaw
|
||||||
|
openclaw gateway stop
|
||||||
|
|
||||||
|
# 2. Backup current (safety)
|
||||||
|
mv ~/.openclaw ~/.openclaw-old
|
||||||
|
|
||||||
|
# 3. Extract backup
|
||||||
|
cd ~
|
||||||
|
tar -xzf ~/openclaw-backups/openclaw-YYYY-MM-DD_HHMM.tar.gz
|
||||||
|
|
||||||
|
# 4. Start OpenClaw
|
||||||
|
openclaw gateway start
|
||||||
|
|
||||||
|
# 5. Verify
|
||||||
|
openclaw status
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rollback if Restore Fails
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm -rf ~/.openclaw
|
||||||
|
mv ~/.openclaw-old ~/.openclaw
|
||||||
|
openclaw gateway start
|
||||||
|
```
|
||||||
|
|
||||||
|
## What's in a Backup
|
||||||
|
|
||||||
|
```
|
||||||
|
~/.openclaw/
|
||||||
|
├── openclaw.json # Main config
|
||||||
|
├── credentials/ # API keys, tokens
|
||||||
|
├── agents/ # Agent configs, auth
|
||||||
|
├── workspace/ # Memory, SOUL.md, files
|
||||||
|
├── telegram/ # Telegram session
|
||||||
|
└── cron/ # Scheduled tasks
|
||||||
|
```
|
||||||
|
|
||||||
|
## Excluded from Backup
|
||||||
|
|
||||||
|
- `completions/` — API response cache (regenerated)
|
||||||
|
- `*.log` — Log files
|
||||||
31
scripts/backup.sh
Normal file
31
scripts/backup.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# OpenClaw Backup Script
|
||||||
|
# Usage: ./backup.sh [backup_dir]
|
||||||
|
|
||||||
|
BACKUP_DIR="${1:-$HOME/openclaw-backups}"
|
||||||
|
DATE=$(date +%Y-%m-%d_%H%M)
|
||||||
|
BACKUP_FILE="$BACKUP_DIR/openclaw-$DATE.tar.gz"
|
||||||
|
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
|
||||||
|
# Create backup (exclude completions cache and logs)
|
||||||
|
tar -czf "$BACKUP_FILE" \
|
||||||
|
--exclude='completions' \
|
||||||
|
--exclude='*.log' \
|
||||||
|
-C "$HOME" .openclaw/ 2>/dev/null
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
|
||||||
|
|
||||||
|
# Rotate: keep only last 7 backups
|
||||||
|
ls -t "$BACKUP_DIR"/openclaw-*.tar.gz 2>/dev/null | tail -n +8 | xargs -r rm
|
||||||
|
|
||||||
|
COUNT=$(ls "$BACKUP_DIR"/openclaw-*.tar.gz 2>/dev/null | wc -l)
|
||||||
|
|
||||||
|
echo "✅ Backup created: $BACKUP_FILE ($SIZE)"
|
||||||
|
echo "📁 Total backups: $COUNT"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "❌ Backup failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user