Skip to content

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

@trevorgordon981

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

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions