💾 Workspace Backup
Automated git-based backup of your OpenClaw workspace to GitHub. Designed to run as a cron job or on-demand.
Features
- - One-command backup with auto-generated commit messages
- Smart
.gitignore for OpenClaw workspaces - Timestamp + changed files summary in commits
- Restore from any point in history
- Cron-friendly (no TTY required)
Setup
1. Initialize the backup repo
CODEBLOCK0
2. Ensure SSH keys are configured
The script uses SSH for push. Make sure your deploy key or SSH key is available.
3. Run the backup
CODEBLOCK1
4. Schedule as cron job
In OpenClaw, create a cron job:
CODEBLOCK2
Or via system crontab:
CODEBLOCK3
Restore Procedures
Restore entire workspace to latest backup
CODEBLOCK4
Restore a specific file from history
CODEBLOCK5
Restore to a specific point in time
CODEBLOCK6
View what changed between backups
CODEBLOCK7
.gitignore
The backup script auto-creates a .gitignore if missing, excluding:
- -
.venv/ — Python virtual environments - INLINECODE3 — Local databases and data files
- INLINECODE4 — Secret environment variables
- INLINECODE5 — Node.js dependencies
- INLINECODE6 — Python bytecode
- INLINECODE7 — Compiled Python files
- INLINECODE8 — macOS metadata
Script Reference
| Script | Description |
|---|
| INLINECODE9 | Main backup script — add, commit, push |
Credits
Built by
M. Abidi |
agxntsix.ai
YouTube |
GitHub
Part of the
AgxntSix Skill Suite for OpenClaw agents.
📅 Need help setting up OpenClaw for your business? Book a free consultation
💾 工作区备份
基于Git的OpenClaw工作区自动备份工具,可备份至GitHub。设计为定时任务或按需运行。
功能特性
- - 一键备份,自动生成提交信息
- 针对OpenClaw工作区的智能.gitignore配置
- 提交中包含时间戳及变更文件摘要
- 支持从任意历史节点恢复
- 兼容定时任务(无需终端交互)
配置指南
1. 初始化备份仓库
bash
cd ~/.openclaw/workspace
git init
git remote add origin git@github.com:YOURUSER/YOURREPO.git
2. 确保SSH密钥已配置
脚本使用SSH协议推送代码。请确保部署密钥或SSH密钥可用。
3. 执行备份
bash
bash {baseDir}/scripts/backup.sh
4. 设置定时任务
在OpenClaw中创建定时任务:
json
{
name: workspace-backup,
schedule: 0 /6 ,
command: bash /home/node/.openclaw/workspace/skills/workspace-backup/{baseDir}/scripts/backup.sh,
description: 每6小时备份工作区至GitHub
}
或通过系统crontab配置:
0 /6 cd /home/node/.openclaw/workspace && bash skills/workspace-backup/{baseDir}/scripts/backup.sh >> /tmp/backup.log 2>&1
恢复操作
恢复整个工作区至最新备份
bash
cd ~/.openclaw/workspace
git fetch origin
git reset --hard origin/main
从历史记录恢复特定文件
bash
git log --oneline -- path/to/file # 查找提交记录
git checkout
-- path/to/file # 恢复文件
恢复到特定时间点
bash
git log --oneline --before=2026-02-01 # 查找该日期附近的提交
git checkout # 进入分离头指针状态
复制所需内容,然后执行:git checkout main
查看备份间的变更内容
bash
git log --oneline -10
git diff --stat
.gitignore配置
备份脚本会自动创建.gitignore文件(若不存在),排除以下内容:
- - .venv/ — Python虚拟环境
- .data/ — 本地数据库及数据文件
- .env — 敏感环境变量
- nodemodules/ — Node.js依赖
- pycache/ — Python字节码缓存
- *.pyc — 编译后的Python文件
- .DSStore — macOS元数据
脚本参考
| 脚本 | 说明 |
|---|
| {baseDir}/scripts/backup.sh | 主备份脚本 — 添加、提交、推送 |
致谢
由 M. Abidi 构建 | agxntsix.ai
YouTube | GitHub
属于 AgxntSix技能套件 的一部分,专为OpenClaw代理设计。
📅 需要为您的企业配置OpenClaw? 预约免费咨询