Skip to content

Add backup/restore utility for config, cron jobs, and session history #13616

Description

@trevorgordon981

Problem

Currently, there's no standardized way to:

  • Backup OpenClaw configuration and state
  • Migrate between environments (dev → staging → prod)
  • Recover from catastrophic failures
  • Export/import cron jobs
  • Archive session history

This makes disaster recovery difficult and environment setup manual.

Proposed Solution

Add built-in backup/restore commands:

CLI Commands

# Export everything
openclaw backup export --output backup.tar.gz

# Export specific components
openclaw backup export --cron-jobs --output cron-backup.json
openclaw backup export --config --output config-backup.json
openclaw backup export --sessions --since 7d --output sessions.jsonl

# Import/restore
openclaw backup import --input backup.tar.gz
openclaw backup import --cron-jobs cron-backup.json --merge

# List backups (if stored in S3/cloud)
openclaw backup list
openclaw backup restore <backup-id>

What Gets Backed Up

Core:

  • openclaw.json config
  • Cron jobs (schedules, payloads, run history)
  • Skills and scripts
  • Workspace files (MEMORY.md, SOUL.md, etc.)

Optional:

  • Session history (transcripts)
  • Exec approvals
  • Node pairing state

Excluded (sensitive):

  • API keys/tokens (use secrets management instead)
  • Logs (too large)

Features

  • Incremental backups: Only changed files since last backup
  • Cloud storage: S3, Azure Blob, GCS integration
  • Encryption: Encrypt backups at rest
  • Scheduled backups: Cron job to auto-backup daily/weekly
  • Disaster recovery: Single command to restore entire gateway

Configuration

{
  "backup": {
    "enabled": true,
    "schedule": "0 2 * * *",
    "storage": {
      "type": "s3",
      "bucket": "openclaw-backups",
      "prefix": "gateway-prod/"
    },
    "retention": {
      "daily": 7,
      "weekly": 4,
      "monthly": 12
    },
    "encryption": {
      "enabled": true,
      "keyId": "aws:kms:us-east-1:key/abc123"
    }
  }
}

Use Cases

  • Disaster recovery: Gateway instance fails, restore on new instance in minutes
  • Environment promotion: Export from dev, import to prod
  • Migration: Move from one cloud provider to another
  • Testing: Clone production config/jobs to staging for testing
  • Compliance: Maintain backups for audit/regulatory requirements
  • Rollback: Restore previous state if config change breaks things

Implementation Ideas

  • Use tar.gz with JSON manifests for each component
  • Support streaming backups for large session history
  • Pre-restore validation (check compatibility, conflicts)
  • Dry-run mode: show what would be restored without actually doing it
  • GitHub Actions: automated backups to repo releases

Impact

Medium — Essential for production deployments, disaster recovery, and environment management.


Example workflow:

# Daily backup to S3 (automated via cron)
openclaw backup export --output s3://openclaw-backups/gateway-prod/2026-02-10.tar.gz

# Disaster: EC2 instance lost
# 1. Spin up new instance
# 2. Restore latest backup
openclaw backup restore s3://openclaw-backups/gateway-prod/latest.tar.gz

# Gateway fully restored with all cron jobs, config, sessions

Related: Memory archival script (already exists for workspace files, but no unified backup/restore)

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.enhancementNew feature or requestimpact: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.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions