The Lifesaving Backup Trick 99% of OpenClaw Users Miss
This guide shows how to protect your OpenClaw configuration by treating the ~/.openclaw directory as a snapshot, using a private GitHub repository for secure, versioned backups that let you roll back, recover from loss, or migrate to a new machine in minutes.
Configuration directory
All OpenClaw data are stored in ~/.openclaw/ with the following sub‑directories: openclaw.json – main configuration (channels, models, agents) credentials/ – API keys, OAuth tokens agents/ – conversation logs and agent settings skills/ – installed skills workspace/ – AI memory and related files
Why use a private GitHub repository
Private = absolute security : only the owner can see the data, API keys remain hidden.
Multi‑device automatic sync : switching computers restores the configuration in about one minute.
Full history : every change is recorded, allowing rollback to any point.
Step‑by‑step tutorial
1. GitHub account (optional)
Open https://github.com and create an account if you do not already have one.
2. Configure SSH key
Two routes are provided:
Route A – send a prompt to OpenClaw to generate the key and return the public key string.
Route B – run the commands manually.
Manual commands:
ls ~/.ssh/id_ed25519.pub
# If the file does not exist, generate a new key
ssh-keygen -t ed25519 -C "my-openclaw" -N "" -f ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
# Add the printed public key in GitHub Settings → SSH and GPG keys → New SSH key
ssh -T [email protected]
# Success is indicated by the phrase "successfully authenticated"3. Create a private repository
Click the + button on GitHub and choose New repository .
Enter a name (e.g., openclaw-config) and select Private .
Leave "Initialize this repository with a README" unchecked.
Click Create repository .
Copy the SSH clone URL, which has the form [email protected]:YOUR_USERNAME/openclaw-config.git.
4. Push the configuration
# Enter the OpenClaw config directory
cd ~/.openclaw
# Initialise a Git repository
git init
# Link to the private repo
git remote add origin [email protected]:YOUR_USERNAME/openclaw-config.git
# Add all files
git add .
# First commit
git commit -m "init config"
# Push (use main or master depending on the remote default)
git push -u origin mainIf the push fails because workspace/ already contains a nested Git repository, remove it first: rm -rf ~/.openclaw/workspace/.git If the remote expects the master branch, replace main with master in the last command.
5. Optional: exclude the credentials/ directory
To prevent the credentials from being stored, add the directory to .gitignore before running git add .:
echo "credentials/" > ~/.openclaw/.gitignore6. Automatic synchronization
After each change, run:
cd ~/.openclaw && git add . && git commit -m "update" && git pushOr create a daily cron job with OpenClaw:
openclaw cron add \
--name "Auto-backup OpenClaw to GitHub" \
--cron "0 23 * * *" \
--message "cd ~/.openclaw && git add . && git commit -m 'Auto backup $(date +%Y-%m-%d_%H-%M)' && git push origin main" \
--timeout-seconds 1207. Restore on a new computer
After registering the new machine and configuring SSH, clone the repository directly into ~/.openclaw:
git clone [email protected]:YOUR_USERNAME/openclaw-config.git ~/.openclawIf credentials/ was excluded, re‑enter the API keys in OpenClaw after cloning.
FAQ
Can I skip the account‑creation step? Yes – start from step 2 if you already have a GitHub account.
git add . reports "workspace/ does not have a commit checked out"? Remove the nested repository with rm -rf ~/.openclaw/workspace/.git and retry.
Why do I get "Permission denied (publickey)"? The SSH key has not been added to GitHub; repeat step 2.
The repository was accidentally made public. Change its visibility in Settings → Danger Zone → Change repository visibility.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ShiZhen AI
Tech blogger with over 10 years of experience at leading tech firms, AI efficiency and delivery expert focusing on AI productivity. Covers tech gadgets, AI-driven efficiency, and leisure— AI leisure community. 🛰 szzdzhp001
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
