Skip to content

Proposal: Improved Backup Design with Configurable Exclusion Rules and Service-Aware Archiving #67990

Description

@JIRBOY

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:

  1. Reliable backups — no more ENOENT failures or locked file errors
  2. Smaller archives — configurable exclusions prevent bloated backups
  3. Cross-platform restore — tar.gz works everywhere
  4. Disaster recovery confidence — knowing that a single archive can restore the entire setup

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions