Skip to content

EntEthAlliance/openclaw-backup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenClaw Backup

Backup of ~/.openclaw/ (configs + workspace) to a private GitHub repo via cron.

Workspace has its own .git managed by OpenClaw, so this tool snapshots it (without .git) into workspace-snapshot/ before each commit. Everything else in ~/.openclaw/ is tracked directly.

Prerequisites

  • git, rsync, crontab
  • A private GitHub repo for your backups (create it via github.com)

SSH setup (deploy key)

Generate a dedicated key (no passphrase — required for cron):

ssh-keygen -t ed25519 -f ~/.ssh/openclaw-backup -N "" -C "openclaw-backup"

Add it as a deploy key with write access in your backup repo: github.com → your backup repo → Settings → Deploy keys → Add deploy key

Configure SSH to use this key. Add to ~/.ssh/config:

Host openclaw-backup
  HostName github.com
  User git
  IdentityFile ~/.ssh/openclaw-backup
  IdentitiesOnly yes

Setup

git clone https://github.com/AlexeyKrasnoperov/openclaw-backup.git ~/openclaw-backup
cd ~/openclaw-backup
chmod +x setup.sh

./setup.sh openclaw-backup:your-username/my-openclaw-data.git

# Custom frequency (every 30 min instead of default 60)
./setup.sh openclaw-backup:your-username/my-openclaw-data.git 30

What's inside

File Purpose
setup.sh One-time provisioning: git init, remote, cron
backup.sh Cron job: snapshot workspace, commit & push
workspace.gitignore Template installed as .gitignore in ~/.openclaw/

How it works

  1. rsync copies ~/.openclaw/workspace/~/.openclaw/workspace-snapshot/ (excluding .git)
  2. git add -A stages everything in ~/.openclaw/ (workspace is in .gitignore, snapshot is not)
  3. Commit and push
  4. rm -rf workspace-snapshot/

This way OpenClaw's own .git in workspace is never touched.

Security notes

  • .gitignore blocks secrets, credentials, databases, logs
  • No sudo, no auto-install
  • Push timeout (120s) prevents hung cron jobs
  • PID lock prevents overlapping runs
  • SSH deploy key scoped to one repo

Restore

Clean machine (~/.openclaw doesn't exist)

git clone openclaw-backup:your-username/my-openclaw-data.git ~/.openclaw
mv ~/.openclaw/workspace-snapshot ~/.openclaw/workspace
cd ~/.openclaw/workspace && git init -b main

# Reinstall cron
cd ~/openclaw-backup
./setup.sh openclaw-backup:your-username/my-openclaw-data.git

Existing install (~/.openclaw already exists)

cd ~/.openclaw
git init -b main
git remote add origin openclaw-backup:your-username/my-openclaw-data.git
git fetch origin main
git checkout origin/main -- .

# Restore workspace files (merge with existing)
rsync -a workspace-snapshot/ workspace/
rm -rf workspace-snapshot

# Reinstall cron
cd ~/openclaw-backup
./setup.sh openclaw-backup:your-username/my-openclaw-data.git

Restore a specific version

cd ~/.openclaw
git log --oneline
git checkout <commit> -- .
rsync -a workspace-snapshot/ workspace/
rm -rf workspace-snapshot

Caveats

  • SQLite databases are excluded. If OpenClaw uses SQLite for state, consider a separate sqlite3 .dump strategy.
  • All log files are excluded (*.log).
  • To change frequency, re-run ./setup.sh <url> <new-minutes>.

Uninstall

crontab -l | grep -v 'openclaw/backup/backup.sh' | crontab -
rm -rf ~/.openclaw/backup ~/.openclaw/.git ~/.openclaw/.gitignore

About

Backup your OpenClaw files to a private GitHub Repo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%