| name | safe-update |
| description | Update OpenClaw from source code. Supports custom project path and branch. Includes pulling latest branch, merging upstream, building and installing, restarting service. Triggered when user asks to update OpenClaw, sync source, merge branch, or rebuild. |
Safe Update
Update OpenClaw from source to the latest version while preserving local changes.
⚠️ Important Warnings
- This script performs git merge from upstream - may cause conflicts if branches have diverged
- Uses npm i -g . for global installation - may require sudo
- Uses systemctl --user restart - will restart the OpenClaw service
- Backup your config before running! (see below)
- Does NOT automatically push - you need to push manually if desired
Requirements
Required binaries (must be installed):
git
npm / node
systemctl (for restarting gateway)
Configuration
Environment Variables (optional)
export OPENCLAW_PROJECT_DIR="/path/to/openclaw"
export OPENCLAW_BRANCH="your-feature-branch"
export DRY_RUN="true"
Or Pass as Arguments
./update.sh --dir /path/to/openclaw --branch your-branch
Pre-run Checklist
Before running, complete these steps:
Workflow
cd /home/ubuntu/projects/openclaw
echo "=== Backing up config files ==="
mkdir -p ~/.openclaw/backups
BACKUP_SUFFIX=$(date +%Y%m%d-%H%M%S)
cp ~/.openclaw/openclaw.json ~/.openclaw/backups/openclaw.json.bak.$BACKUP_SUFFIX
echo "✅ Backed up: openclaw.json"
if [ -f ~/.openclaw/agents/main/agent/auth-profiles.json ]; then
cp ~/.openclaw/agents/main/agent/auth-profiles.json \
~/.openclaw/backups/auth-profiles.json.bak.$BACKUP_SUFFIX
echo "✅ Backed up: auth-profiles.json"
fi
echo "💡 Backups saved to: ~/.openclaw/backups/"
echo ""
git remote add upstream https://github.com/openclaw/openclaw.git 2>/dev/null || true
git fetch upstream
git checkout $BRANCH
git merge upstream/$BRANCH
echo "=== Full Changelog ==="
CURRENT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v$(node -e 'console.log(require("./package.json").version)')")
echo "Current version: $CURRENT_TAG"
echo
npm run build
npm i -g .
NEW_VERSION=$(openclaw --version)
systemctl --user restart openclaw-gateway
3
-v openclaw &>/dev/null;
openclaw health 2>/dev/null || openclaw status
Quick Script
Run scripts/update.sh to automatically complete all steps above.
Command Line Options
./update.sh [OPTIONS]
Options:
--dir PATH OpenClaw project directory (default: $HOME/projects/openclaw)
--branch NAME Git branch to update (default: main)
--dry-run Show what would be done without executing
--help Show this help message
Examples
./update.sh
./update.sh --branch feat/my-branch
./update.sh --dry-run
./update.sh --dir /opt/openclaw --branch main
Notes
- Merge may cause conflicts - if conflicts occur, resolve manually and continue
- Manual push - script does not auto-push, run
git push manually if needed
- Service restart - gateway will restart, brief downtime expected
- Backup first - always backup before updating!
Troubleshooting
Git Conflicts During Merge
git add .
git merge --continue
Build Fails
rm -rf node_modules dist
npm install
npm run build
Gateway Won't Start
systemctl --user status openclaw-gateway
journalctl --user -u openclaw-gateway -n 50