Summary
Propose an improved backup architecture for OpenClaw that addresses current issues with file locking, symlink handling, exclusion rule configurability, and backup size optimization.
Problem Statement
The current openclaw backup create command has several known issues:
Proposed Architecture
1. Service-Aware Backup Lifecycle
1. Detect locked files (SQLite, WAL files)
2. If locked → openclaw gateway stop
3. Create tar.gz archive
4. Restore → openclaw gateway start
5. If user rejects service control → fall back to best-effort with warning
This solves #67417 by eliminating the race condition between backup enumeration and session cleanup.
2. Configurable Exclusion Rules
Exclusion rules should be stored in a config file, not hardcoded:
{
"excluded_extensions": ["log", "tmp", "pyc", "bak", "swp"],
"excluded_folders": [
"node_modules", ".git", "__pycache__", ".venv",
"extensions", "browser", "delivery-queue", "flows",
"skills-backup"
],
"excluded_files": [".DS_Store", "Thumbs.db"]
}
Why this matters: Every OpenClaw installation is different. Some users have 100+ skills, some run in environments with node_modules or browser caches. Without configurability, backups either include gigabytes of rebuildable data or exclude things users actually need.
3. Symlink-Aware Traversal
Skip symbolic links and junction points entirely using FileAttributes.ReparsePoint (Windows) or lstat checks (Unix). This prevents:
4. Output Format
Use tar.gz for universal compatibility:
- Zero external dependencies on most platforms
- Paths stored as absolute (e.g.,
C:\Users\...\) for disaster recovery
- Restore command:
tar -xzf backup.tar.gz
- Compressed size typically 4-10x smaller than raw data
5. Two Backup Modes
| Mode |
What It Includes |
Typical Size |
Use Case |
config-only |
openclaw.json, credentials, cron jobs, skills, devices |
< 5 MB |
Quick migration, config backup |
full |
Config + workspace + memory + persona files |
10-50 MB |
Disaster recovery |
Reference Implementation
I built a standalone tool implementing this design:
- Repository: JIRBOY/openclaw-backup
- Stack: .NET 8, zero external dependencies (
System.Formats.Tar + GZipStream)
- Features: Service management (gateway stop/start), UAC auto-elevation, XML-configurable exclusions, backup rotation, dry-run mode
- Real-world results on a typical installation:
- Naive scan: 13,400 files, 256 MB
- With exclusion rules: 1,995 files, 8.6 MB compressed
Related Issues
Impact
This would give OpenClaw users:
- Reliable backups — no more ENOENT failures or locked file errors
- Smaller archives — configurable exclusions prevent bloated backups
- Cross-platform restore — tar.gz works everywhere
- Disaster recovery confidence — knowing that a single archive can restore the entire setup
Summary
Propose an improved backup architecture for OpenClaw that addresses current issues with file locking, symlink handling, exclusion rule configurability, and backup size optimization.
Problem Statement
The current
openclaw backup createcommand has several known issues:Proposed Architecture
1. Service-Aware Backup Lifecycle
This solves #67417 by eliminating the race condition between backup enumeration and session cleanup.
2. Configurable Exclusion Rules
Exclusion rules should be stored in a config file, not hardcoded:
{ "excluded_extensions": ["log", "tmp", "pyc", "bak", "swp"], "excluded_folders": [ "node_modules", ".git", "__pycache__", ".venv", "extensions", "browser", "delivery-queue", "flows", "skills-backup" ], "excluded_files": [".DS_Store", "Thumbs.db"] }Why this matters: Every OpenClaw installation is different. Some users have 100+ skills, some run in environments with
node_modulesor browser caches. Without configurability, backups either include gigabytes of rebuildable data or exclude things users actually need.3. Symlink-Aware Traversal
Skip symbolic links and junction points entirely using
FileAttributes.ReparsePoint(Windows) orlstatchecks (Unix). This prevents:projects -> /d/Research/Projects)4. Output Format
Use
tar.gzfor universal compatibility:C:\Users\...\) for disaster recoverytar -xzf backup.tar.gz5. Two Backup Modes
config-onlyfullReference Implementation
I built a standalone tool implementing this design:
System.Formats.Tar+GZipStream)Related Issues
Impact
This would give OpenClaw users: