Skip to main content
The backup commands help you create, restore, and manage backups of your OpenClaw stack data, including PostgreSQL dumps and Qdrant snapshots.

Subcommands

create

Create a backup of the stack (PostgreSQL dump, Qdrant snapshot).
create-better-openclaw backup create [options]

Options

--dir
string
default:"."
Project directory containing the stack (default: current directory).
--output
string
Output directory for the backup archive. If not specified, backups are saved to ./backups/ in the stack directory.
--json
boolean
default:"false"
Output results as JSON for programmatic use.

restore

Restore from a backup archive.
create-better-openclaw backup restore <file> [options]

Arguments

file
string
required
Path to the backup .tar.gz file to restore.

Options

--dir
string
default:"."
Project directory containing the stack (default: current directory).
--json
boolean
default:"false"
Output results as JSON for programmatic use.

list

List available backups.
create-better-openclaw backup list [options]

Options

--dir
string
default:"."
Project directory containing the stack (default: current directory).
--json
boolean
default:"false"
Output results as JSON for programmatic use.

Examples

Create a backup

cd my-stack
create-better-openclaw backup create
Output:
Creating backup...

  Backing up PostgreSQL...
 Database dump: openclaw.sql (12.4 MB)
  
  Backing up Qdrant...
 Snapshot created: qdrant-snapshot.tar (45.2 MB)
  
  Creating archive...
 Backup saved: ./backups/openclaw-backup-2026-03-03-14-32-15.tar.gz (57.6 MB)

Backup complete!

Create backup with custom output location

create-better-openclaw backup create --output /mnt/backups
Output:
Creating backup...

  Backing up PostgreSQL...
 Database dump: openclaw.sql (12.4 MB)
  
  Backing up Qdrant...
 Snapshot created: qdrant-snapshot.tar (45.2 MB)
  
  Creating archive...
 Backup saved: /mnt/backups/openclaw-backup-2026-03-03-14-32-15.tar.gz (57.6 MB)

Backup complete!

List available backups

create-better-openclaw backup list
Output:
Available Backups:

  openclaw-backup-2026-03-03-14-32-15.tar.gz    57.6 MB    2 hours ago
  openclaw-backup-2026-03-02-10-15-42.tar.gz    56.8 MB    1 day ago
  openclaw-backup-2026-03-01-03-00-00.tar.gz    54.2 MB    2 days ago

Total: 3 backups (168.6 MB)

Restore from backup

create-better-openclaw backup restore ./backups/openclaw-backup-2026-03-03-14-32-15.tar.gz
Output:
Restoring from backup...

 Warning: This will overwrite existing data.
  
  Stopping services...
 All services stopped
  
  Extracting archive...
 Extracted to temp directory
  
  Restoring PostgreSQL...
 Database restored: openclaw.sql
  
  Restoring Qdrant...
 Snapshot restored
  
  Starting services...
 postgres
 redis
 qdrant
 openclaw

Restore complete!

JSON output

create-better-openclaw backup create --json
Output:
{
  "success": true,
  "file": "./backups/openclaw-backup-2026-03-03-14-32-15.tar.gz",
  "size": 60395520,
  "timestamp": "2026-03-03T14:32:15Z",
  "contents": [
    {
      "service": "postgres",
      "file": "openclaw.sql",
      "size": 13008896
    },
    {
      "service": "qdrant",
      "file": "qdrant-snapshot.tar",
      "size": 47386624
    }
  ]
}
create-better-openclaw backup list --json
Output:
{
  "backups": [
    {
      "file": "openclaw-backup-2026-03-03-14-32-15.tar.gz",
      "path": "./backups/openclaw-backup-2026-03-03-14-32-15.tar.gz",
      "size": 60395520,
      "created": "2026-03-03T14:32:15Z",
      "age": "2h"
    },
    {
      "file": "openclaw-backup-2026-03-02-10-15-42.tar.gz",
      "path": "./backups/openclaw-backup-2026-03-02-10-15-42.tar.gz",
      "size": 59572224,
      "created": "2026-03-02T10:15:42Z",
      "age": "1d"
    }
  ],
  "total": 2,
  "totalSize": 119967744
}

Backup contents

Backups include:

PostgreSQL

  • Full database dump (pg_dump)
  • Schema and data
  • Sequences and indexes

Qdrant

  • Vector database snapshot
  • Collections and vectors
  • Indexes and metadata

Configuration (optional)

  • .env file (secrets redacted)
  • Custom configuration files

Not included

  • Docker images
  • Log files
  • Temporary data
  • Build artifacts

Use cases

Daily automated backups

#!/bin/bash
# Run daily at 3 AM via cron
# 0 3 * * * /opt/openclaw/backup.sh

cd /opt/my-stack
create-better-openclaw backup create --output /mnt/backups

# Keep only last 7 days
find /mnt/backups -name "openclaw-backup-*.tar.gz" -mtime +7 -delete

Pre-update backup

#!/bin/bash
echo "Creating backup before update..."
create-better-openclaw backup create

echo "Updating stack..."
if ! create-better-openclaw update; then
  echo "Update failed! Restoring from backup..."
  LATEST=$(create-better-openclaw backup list --json | jq -r '.backups[0].path')
  create-better-openclaw backup restore "$LATEST"
  exit 1
fi

echo "Update successful!"

Disaster recovery

# On original server
create-better-openclaw backup create --output /mnt/backup
scp /mnt/backup/openclaw-backup-*.tar.gz user@new-server:/tmp/

# On new server
create-better-openclaw generate my-stack --preset researcher
cd my-stack
create-better-openclaw backup restore /tmp/openclaw-backup-*.tar.gz

Migrate between environments

# Development to staging
cd ~/dev-stack
create-better-openclaw backup create
scp ./backups/openclaw-backup-*.tar.gz staging:/opt/staging-stack/backups/

# On staging
cd /opt/staging-stack
create-better-openclaw backup restore ./backups/openclaw-backup-*.tar.gz

Testing and rollback

# Before making changes
create-better-openclaw backup create

# Make changes, test
create-better-openclaw add ollama
docker compose up -d

# If issues, rollback
LATEST=$(create-better-openclaw backup list --json | jq -r '.backups[0].path')
create-better-openclaw backup restore "$LATEST"

Best practices

Backup frequency

  • Production: Daily automated backups
  • Development: Before major changes
  • Staging: Before deployments

Retention policy

# Keep last 7 daily backups
find ./backups -name "*.tar.gz" -mtime +7 -delete

# Or keep last N backups
ls -t ./backups/*.tar.gz | tail -n +8 | xargs rm -f

Off-site storage

# Upload to S3
aws s3 cp ./backups/openclaw-backup-*.tar.gz s3://my-backups/openclaw/

# Or rsync to remote server
rsync -av ./backups/ user@backup-server:/backups/openclaw/

Verify backups

# Test restore in isolated environment
docker compose -f docker-compose.test.yml up -d
create-better-openclaw backup restore --dir ./test-stack ./backups/latest.tar.gz
# Verify data integrity
docker compose -f docker-compose.test.yml down

Monitor backup size

# Alert if backup size changes significantly
CURRENT_SIZE=$(ls -l ./backups/latest.tar.gz | awk '{print $5}')
LAST_SIZE=$(ls -l ./backups/previous.tar.gz | awk '{print $5}')

if [ $((CURRENT_SIZE - LAST_SIZE)) -gt 10485760 ]; then  # 10MB threshold
  echo "Warning: Backup size increased by >10MB"
fi

Troubleshooting

Backup fails: Permission denied

Ensure Docker containers have proper permissions:
sudo chown -R 999:999 ./data/postgres  # PostgreSQL user
sudo chown -R 1000:1000 ./data/qdrant  # Qdrant user

Backup takes too long

For large databases, consider:
  • Incremental backups
  • Compression level tuning
  • Parallel dump/restore

Restore fails: Version mismatch

Ensure compatible versions:
# Check versions in backup metadata
tar -xzf backup.tar.gz metadata.json
cat metadata.json

# Match image versions
docker compose pull

Corrupted backup

Verify backup integrity:
# Check archive
tar -tzf backup.tar.gz > /dev/null

# Check SQL dump
tar -xzf backup.tar.gz openclaw.sql
psql -d postgres -f openclaw.sql --dry-run

Build docs developers (and LLMs) love