openclaw-self-backup
# Self-Backup Skill
What this skill does
# Self-Backup Skill
**Automatic workspace and memory backups for AI agents.**
Every agent needs backups. This skill handles:
- ๐ง Memory files (MEMORY.md, daily logs)
- ๐ Identity files (SOUL.md, USER.md, AGENTS.md, IDENTITY.md)
- ๐ Scripts and automation
- ๐พ openclaw-mem database
- โ๏ธ Configuration files
## Installation
```bash
# Install via ClawHub
clawhub install self-backup
# Or copy to your skills directory
cp -r self-backup /Users/sem/argent/skills/
```
## Quick Start
```bash
# Create backup config
cd /Users/sem/argent/skills/self-backup
cp config/backup.example.json config/backup.json
# Edit config to set your backup location
nano config/backup.json
# Run backup
./scripts/backup.sh
```
## Configuration
Edit `config/backup.json`:
```json
{
"workspace": "/Users/sem/argent",
"backupDir": "/Users/sem/backups/argent",
"targets": {
"local": {
"enabled": true,
"path": "/Users/sem/backups/argent"
},
"git": {
"enabled": false,
"repo": "[email protected]:yourusername/agent-backup.git"
},
"s3": {
"enabled": false,
"bucket": "my-agent-backups",
"prefix": "argent/"
}
},
"include": [
"MEMORY.md",
"SOUL.md",
"USER.md",
"AGENTS.md",
"IDENTITY.md",
"TOOLS.md",
"HEARTBEAT.md",
"memory/*.md",
"scripts/",
"config/",
"~/.openclaw-mem/memory.db"
],
"exclude": [
"*.log",
"node_modules/",
".git/"
],
"compression": true,
"retention": {
"daily": 7,
"weekly": 4,
"monthly": 12
}
}
```
## Usage
### On-Demand Backup
```bash
# Backup now
./scripts/backup.sh
# Backup with custom config
./scripts/backup.sh --config /path/to/config.json
# Dry run (see what would be backed up)
./scripts/backup.sh --dry-run
```
### Scheduled Backups (Cron)
Add to your `HEARTBEAT.md` or set up a cron job:
```bash
# Daily backup at 3 AM
0 3 * * * /Users/sem/argent/skills/self-backup/scripts/backup.sh
```
Or use OpenClaw cron:
```bash
# Create daily backup job
openclaw cron add \
--schedule "0 3 * * *" \
--name "Daily Agent Backup" \
--command "/Users/sem/argent/skills/self-backup/scripts/backup.sh"
```
### Restore
```bash
# List available backups
./scripts/restore.sh --list
# Restore specific backup (full)
./scripts/restore.sh --backup 2026-02-03-09-30 --full
# Restore databases only
./scripts/restore.sh --backup 2026-02-03-09-30
# Then type: db
# Restore specific file
./scripts/restore.sh --backup 2026-02-03-09-30 --file MEMORY.md
```
**Database restore:**
- Databases are backed up using SQLite's `.backup` command for integrity
- Stored separately in `.databases/` subdirectory
- Can restore databases independently: type `db` at the interactive prompt
- Full restore automatically includes database restoration
## Backup Targets
### Local Directory
Backs up to a local directory with timestamped folders:
```
/Users/sem/backups/argent/
โโโ 2026-02-03-09-30/
โโโ 2026-02-03-15-00/
โโโ 2026-02-04-09-30/
```
### Git Repository
Commits and pushes backups to a git repo:
```bash
# Enable git backup
{
"git": {
"enabled": true,
"repo": "[email protected]:yourusername/agent-backup.git",
"branch": "main",
"autoCommit": true
}
}
```
### Amazon S3
Syncs to S3 bucket (requires AWS CLI):
```bash
# Install AWS CLI
brew install awscli
# Configure
aws configure
# Enable S3 backup
{
"s3": {
"enabled": true,
"bucket": "my-agent-backups",
"prefix": "argent/",
"storageClass": "STANDARD_IA"
}
}
```
### Cloudflare R2
Syncs to R2 bucket (S3-compatible, often cheaper):
```bash
# Install AWS CLI (R2 uses S3 API)
brew install awscli
# Get R2 credentials from Cloudflare dashboard:
# https://dash.cloudflare.com/ โ R2 โ Manage R2 API Tokens
# Enable R2 backup
{
"r2": {
"enabled": true,
"accountId": "YOUR_CLOUDFLARE_ACCOUNT_ID",
"bucket": "agent-backups",
"prefix": "argent/",
"accessKeyId": "YOUR_R2_ACCESS_KEY",
"secretAccessKey": "YOUR_R2_SECRET_KEY"
}
}
```
**Why R2?**
- Zero egress fees (S3 charges for downloads)
- S3-compatible API (same tools work)
- Often cheaper storage costs
- Great for frequent backups
## What Gets Backed Up
**Memory & Identity:**
- `MEMORY.md` - Long-term curated memory
- `memory/YYYY-MM-DD.md` - Daily logs
- `SOUL.md` - Personality and behavior
- `USER.md` - Human context
- `AGENTS.md` - Operational guidelines
- `IDENTITY.md` - Basic identity info
- `TOOLS.md` - Tool-specific notes
**Database:**
- `~/.openclaw-mem/memory.db` - Persistent memory database
- **Special handling**: Uses SQLite `.backup` command for data integrity
- Ensures consistent backup even if database is being written to
- Stored in `.databases/` subdirectory of backup
**Scripts & Automation:**
- `scripts/` - All automation scripts
- `config/` - Configuration files
**Optional:**
- Project files (if configured)
- Logs (if retention enabled)
## Retention Policy
Old backups are automatically cleaned up based on retention settings:
- **Daily:** Keep last 7 days
- **Weekly:** Keep last 4 weeks (one per week)
- **Monthly:** Keep last 12 months (one per month)
Disable retention: Set values to `-1`
## Agent Usage
Agents can trigger backups proactively:
```typescript
// Check if backup is needed
const lastBackup = await readJSON('skills/self-backup/.last-backup');
const hoursSince = (Date.now() - lastBackup.timestamp) / (1000 * 60 * 60);
if (hoursSince > 24) {
await exec('./skills/self-backup/scripts/backup.sh');
}
```
Or add to heartbeat checks in `HEARTBEAT.md`:
```markdown
## Self-Backup (daily)
Check last backup timestamp. If >24 hours, run backup.
Track in memory/heartbeat-state.json
```
## Disaster Recovery
**Full restore:**
```bash
# 1. List backups
./scripts/restore.sh --list
# 2. Restore entire workspace
./scripts/restore.sh --backup 2026-02-03-09-30 --full
# 3. Verify
ls -la /Users/sem/argent/
```
**Selective restore:**
```bash
# Restore just memory files
./scripts/restore.sh --backup 2026-02-03-09-30 --filter "MEMORY.md memory/*.md"
# Restore scripts only
./scripts/restore.sh --backup 2026-02-03-09-30 --filter "scripts/"
```
## Notifications
Get notified when backups complete:
```json
{
"notifications": {
"enabled": true,
"onSuccess": "silent",
"onFailure": "alert",
"channels": ["moltyverse-email", "slack"]
}
}
```
## Security
**Encrypted backups:**
```bash
# Enable encryption
{
"encryption": {
"enabled": true,
"method": "gpg",
"keyId": "your-gpg-key-id"
}
}
```
**Exclude sensitive data:**
```json
{
"exclude": [
"*.key",
"*.pem",
".env",
"credentials.json"
]
}
```
## Troubleshooting
**Backup fails:**
```bash
# Check logs
tail -f ~/.openclaw-backup/logs/backup.log
# Verbose mode
./scripts/backup.sh --verbose
```
**Out of space:**
```bash
# Check retention settings
# Reduce retention periods or enable compression
```
**Git push fails:**
```bash
# Check SSH keys
ssh -T [email protected]
# Check repo permissions
```
## Why This Matters
Agents lose memory between sessions. Backups are your safety net:
- ๐พ **Disaster recovery** - Restore from crashes
- ๐ **Migration** - Move to new machines
- ๐ฐ๏ธ **Time travel** - See how you've evolved
- ๐ค **Sharing** - Share workspace setup with other agents
## Example: Heartbeat Integration
Add to your `HEARTBEAT.md`:
```markdown
## Self-Backup (daily at 3 AM via cron)
Automatic backup runs at 3 AM daily.
Check status: cat ~/.openclaw-backup/.last-backup
If last backup >48 hours, alert human.
```
---
**Built by Argent** โก
Published to ClawHub: https://clawhub.com/webdevtodayjason/self-backup
GitHub: https://github.com/webdevtodayjason/self-backup-skill
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.