How do you back up an OpenClaw workspace in a private git repository, and what must stay out of it?
answer
- the workspace is not ~/.openclaw
- new workspaces start as repos
- private remote, no README
- config, credentials, SQLite stay out
- placeholders instead of keys
basics
~20 sCommit the workspace (default ~/.openclaw/workspace: AGENTS.md, SOUL.md, IDENTITY.md, USER.md, memory/) to a private remote. Keep ~/.openclaw/ out of it, including openclaw.json, credentials/ and the SQLite databases, and put no API keys or tokens in workspace files.
solid answer
~30 sThe workspace and `~/.openclaw/` are separate on purpose. If git is installed, a brand-new workspace is already a repository; add `AGENTS.md`, `SOUL.md`, `IDENTITY.md`, `USER.md` and `memory/`, create a private remote without a README, and push. Never commit `openclaw.json`, `credentials/`, the shared `state/openclaw.sqlite` or the per-agent `openclaw-agent.sqlite` with auth profiles and transcripts, or managed skills. Even in a private repo, keep API keys and passwords out of workspace files and use placeholders. To move machines, clone, point `agents.entries.<agentId>.workspace` at it and check with `openclaw agents list`. Config and sessions are backed up separately with `openclaw backup create`.
code
bash · 5 linescd ~/.openclaw/workspace
git init
git add AGENTS.md SOUL.md IDENTITY.md USER.md memory/
git commit -m "Add agent workspace"
gh repo create openclaw-workspace --private --source . --remote origin --pushgo deeper
Remember the split: the workspace folder goes into a private git repository, the ~/.openclaw directory with config and credentials does not.
List what lives where, including the SQLite databases, and walk through creating the private remote and moving the workspace to a new machine.
Show you review memory files before pushing, use placeholders for secrets, and back up config and sessions with OpenClaw's backup commands rather than raw file copies.
Set a team policy: who holds the workspace remote, how its access is audited, how state archives are encrypted, and how a leaked backup triggers credential rotation.
## Two separate places on disk An OpenClaw install keeps its state in two locations that must be treated differently: - the **workspace**, by default `~/.openclaw/workspace`: the agent's Markdown files, which OpenClaw's docs say to treat as private memory and back up; - **`~/.openclaw/`** itself: config, credentials and SQLite databases, which must **never** be committed to the workspace repository. Mixing them up is the classic backup mistake: either secrets end up in git, or the owner believes a git push protects config and sessions that were never in it. ## Setting up the repository Do this on the machine where the Gateway runs, because that is where the workspace lives. 1. If git is installed, a **brand-new workspace is initialised as a repository automatically**. Otherwise run `git init` inside it. 2. Add the persona and memory files: `AGENTS.md`, `SOUL.md`, `IDENTITY.md`, `USER.md` and the `memory/` folder, then commit. 3. Create a **private** repository on your git host. Do not initialise it with a README, which avoids a merge conflict on the first push. 4. Add the remote and push; with the GitHub CLI, `gh repo create ... --private --source . --remote origin --push` does both. 5. From then on, commit and push after meaningful changes, the same as any repository. ## What goes in - The bootstrap files: operating rules, persona, identity record, user model. - The `memory/` daily logs and a curated `MEMORY.md` if you use one. - Workspace skills under `skills/`, if you keep any there. - Avatars and other small assets the ritual created. ## What stays out | Path under `~/.openclaw/` | What it holds | |---|---| | `openclaw.json` | the config | | `credentials/` | channel and provider state, legacy OAuth import data | | `state/openclaw.sqlite` | shared workspace setup state and attestations | | `agents/<agentId>/agent/openclaw-agent.sqlite` | model auth profiles, routing state, sessions, transcripts, memory index state | | `agents/<agentId>/sessions/` | legacy migration sources and archives | | `skills/` | managed skills | ## No secrets, even in a private repository A private remote is still a copy of your data on someone else's server, readable by anyone who gets a token for it. The workspace guidance is explicit: - no API keys, OAuth tokens, passwords or private credentials in any workspace file; - nothing from `~/.openclaw/`; - no raw chat dumps or sensitive attachments. If a file needs to refer to a secret, write a placeholder and keep the real value in a password manager, environment variables or `~/.openclaw/`. A starter `.gitignore` covers `.env`, `**/*.key`, `**/*.pem` and `**/secrets*`. Memory files deserve a look before each push for the same reason: the agent writes them, and it may have written down something sensitive the owner said. ## Before each push The agent writes into the workspace too, so a commit is not only your own edits. A short routine keeps the remote clean: - run `git status` and read what changed, especially under `memory/`; - look for pasted tokens, one-time codes or addresses that should not leave the host; - check that no `.env`, key or certificate file slipped past `.gitignore`; - confirm the remote is still private after any change of host or organisation. If a secret was pushed, removing the line is not enough: rotate the credential, because the history already holds it. ## Moving to a new machine 1. Clone the private repository to the desired path. 2. Point the agent at it: `agents.entries.<agentId>.workspace` in `openclaw.json`, or `agents.defaults.workspace` for a sole agent with no per-agent override. 3. Run `openclaw agents list` and confirm the agent shows the cloned path before starting the Gateway. Re-running onboarding is not needed. 4. Copy sessions separately, only if you need them: the per-agent `openclaw-agent.sqlite`, outside git, taken from a stopped Gateway or a backup archive rather than a live file. ## State backup is a different tool The git repository protects the workspace only. Config, credentials and session history live in SQLite and are backed up with OpenClaw's own commands, such as `openclaw backup create --verify`, which capture committed state safely. Never copy live `.sqlite`, `-wal` or `-shm` files from a running Gateway; they can be torn. Those archives contain auth profiles and credentials, so store them encrypted and restricted like the live state directory.
- How do you bring the workspace up on a new machine without re-running onboarding?Clone the private repository, set `agents.entries.<agentId>.workspace` (or `agents.defaults.workspace` for a sole agent) to the cloned path in `openclaw.json`, and run `openclaw agents list` to confirm the agent points there before starting the Gateway. Copy the per-agent session database separately only if you need old sessions.
- If the git repository covers only the workspace, how are config and sessions protected?With OpenClaw's backup commands, for example `openclaw backup create --verify`, which capture the SQLite state safely while the Gateway runs. Copying live `.sqlite` files can produce a torn copy. The archives include auth profiles and credentials, so they are stored encrypted and access-restricted, never pushed to the workspace remote.
- Commit the whole ~/.openclaw directory so config and workspace stay together.
- A private repository makes it safe to keep API keys in AGENTS.md.
- Copying the live .sqlite files is a fine backup of sessions.
- The workspace repo also backs up channel credentials and transcripts.