Skip to content

Commit 4dc4080

Browse files
committed
docs(backup): centralize archive restore guidance
Punchcard-Session: calm-cedar-workshop-by
1 parent b3f3343 commit 4dc4080

2 files changed

Lines changed: 102 additions & 101 deletions

File tree

‎docs/cli/backup.md‎

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ openclaw backup sqlite restore ~/Backups/openclaw-sqlite/<snapshot-id> --target
3131
Archive `create` and `verify`, plus SQLite `create`, `list`, `verify`, and
3232
`restore`, accept `--json` for one machine-readable result on stdout.
3333

34-
OpenClaw does not currently provide an `openclaw backup restore` command. Restore is a manual copy-back flow guided by the embedded `manifest.json`. See [Restore from an archive](#restore-from-an-archive).
34+
OpenClaw does not currently provide an `openclaw backup restore` command. Follow [Restore a full archive](/install/backups#restore-a-full-archive) for the manual, manifest-driven copy-back flow.
3535

3636
## Notes
3737

@@ -125,93 +125,6 @@ For a partial backup in that situation, rerun with `--no-include-workspace`: it
125125

126126
`--only-config` also works when the config is malformed, since it does not parse the config for workspace discovery.
127127

128-
## Restore from an archive
129-
130-
OpenClaw does not currently provide an `openclaw backup restore` command. Archives are plain `.tar.gz` files, and the embedded `manifest.json` records the source paths and archive paths needed for a manual restore.
131-
132-
Start only from an archive you created or otherwise trust. `openclaw backup verify` checks archive structure and payload layout, but it does not authenticate the archive or make untrusted content safe.
133-
134-
### Inspect and stage the archive
135-
136-
Verify the archive before extracting it, then extract into a private temporary directory. The block sets `set -euo pipefail` so a failed `openclaw backup verify` stops the script before any extraction:
137-
138-
```bash
139-
set -euo pipefail
140-
141-
ARCHIVE=./2026-03-09T08-00-00.000+08-00-openclaw-backup.tar.gz
142-
143-
openclaw backup verify "$ARCHIVE"
144-
145-
restore_dir="$(mktemp -d -t openclaw-restore.XXXXXX)"
146-
trap 'rm -rf "$restore_dir"' EXIT
147-
148-
tar -xzf "$ARCHIVE" -C "$restore_dir"
149-
manifest_path="$(find "$restore_dir" -mindepth 2 -maxdepth 2 -name manifest.json -print -quit)"
150-
test -n "$manifest_path"
151-
cat "$manifest_path"
152-
```
153-
154-
Treat the restore directory as sensitive. It may contain credentials, auth profiles, sessions, and workspace data from the archive. Remove it when you are done inspecting or restoring; the `trap` in the example handles cleanup when the shell exits.
155-
156-
The manifest reports `archiveRoot`, `paths.stateDir`, `paths.configPath`, `paths.oauthDir`, `paths.workspaceDirs`, and an `assets[]` list. Each asset includes its `kind`, original `sourcePath`, and `archivePath` inside the tarball. Use those manifest fields as the source of truth before copying anything back.
157-
158-
Do not derive the archive root from the `.tar.gz` filename. `openclaw backup create --output` can write to a custom filename while the embedded `archiveRoot` remains timestamp-derived.
159-
160-
### Archive layout
161-
162-
The archive stores the manifest and payload under one root directory:
163-
164-
```text
165-
<archive-root>/manifest.json
166-
<archive-root>/payload/posix/<absolute-source-path-without-leading-slash>/...
167-
<archive-root>/payload/windows/<DRIVE>/<rest>/...
168-
<archive-root>/payload/relative/<relative-source-path>/...
169-
```
170-
171-
For example, a POSIX source path like `/home/alex/.openclaw` is stored under `<archive-root>/payload/posix/home/alex/.openclaw`. The manifest asset's `archivePath` contains the exact path to copy from, so prefer that over reconstructing paths by hand.
172-
173-
### Restore selected paths
174-
175-
Before overwriting a live install:
176-
177-
- Stop the Gateway and any node hosts that use the files you are restoring.
178-
- Make a fresh backup of the current state, or move the current directories aside.
179-
- Restore the smallest set of paths needed, such as only the config asset for a config rollback.
180-
- Use `manifest.json` to map each asset's `archivePath` to the target path you want to restore.
181-
- Restart OpenClaw and run `openclaw doctor` after the restore.
182-
183-
For example, to restore the state asset into the current user's default state directory:
184-
185-
```bash
186-
set -euo pipefail
187-
188-
state_archive_path="$(
189-
node -e 'const fs = require("node:fs"); const manifest = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(manifest.assets.find((asset) => asset.kind === "state")?.archivePath ?? "");' "$manifest_path"
190-
)"
191-
test -n "$state_archive_path"
192-
193-
state_target="$HOME/.openclaw"
194-
state_backup="$HOME/.openclaw.pre-restore.$(date +%s)"
195-
196-
openclaw gateway stop
197-
198-
if [ -e "$state_target" ]; then
199-
mv "$state_target" "$state_backup"
200-
fi
201-
mkdir -p "$state_target"
202-
cp -a "$restore_dir/$state_archive_path"/. "$state_target"/
203-
204-
openclaw doctor
205-
openclaw gateway start
206-
openclaw status
207-
```
208-
209-
For a same-machine restore, the manifest `sourcePath` values are usually the intended targets. For a new machine or different home directory, choose the new target paths first, then copy only the matching asset payloads into those locations.
210-
211-
For a full local restore, the usual targets are the state directory, active config file, credentials directory, and any workspace directories listed in the manifest. Do not restore onto a running service.
212-
213-
Before a full restore, review [What gets backed up](#what-gets-backed-up): archives intentionally omit volatile files, plugin dependency trees, and installer-managed runtime roots such as state-local `tmp/`. Recreate those artifacts after restore.
214-
215128
## Size and performance
216129

217130
OpenClaw does not enforce a built-in maximum backup size or per-file size limit. An archive write that produces no data for five minutes fails and removes its partial temporary file instead of hanging indefinitely. Practical limits otherwise come from:
@@ -229,3 +142,4 @@ Large workspaces are usually the main driver of archive size. Use `--no-include-
229142

230143
- [CLI reference](/cli)
231144
- [Migrating an OpenClaw install](/install/migrating)
145+
- [Restore a full archive](/install/backups#restore-a-full-archive)

‎docs/install/backups.md‎

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,106 @@ encryption rules.
140140

141141
## Restore
142142

143-
Restore is deliberately explicit; nothing overwrites a live database in
144-
place:
145-
146-
1. Stop the Gateway.
147-
2. For archives: extract into a staging directory and follow the
148-
`manifest.json` source-to-archive mapping to put files back; see
149-
[Updating](/install/updating#rollback) for the rollback workflow.
150-
3. For snapshots: `openclaw backup sqlite restore <snapshot-directory>
151-
--target <new-database-path>` writes a re-verified database to a fresh
152-
target. Move it into place while the Gateway is stopped.
153-
4. For Litestream: `litestream restore` writes a fresh database file; move it
154-
into place the same way.
155-
5. Start the Gateway and check `openclaw health` and `openclaw doctor`.
143+
Restore is deliberately explicit; nothing overwrites live state in place.
144+
145+
### Restore a full archive
146+
147+
Start only from an archive you created or otherwise trust. `openclaw backup
148+
verify` checks archive structure and payload layout, but it does not
149+
authenticate the archive or make untrusted content safe.
150+
151+
Before a full restore, review [What gets backed
152+
up](/cli/backup#what-gets-backed-up). Archives intentionally omit volatile
153+
files, plugin dependency trees, and installer-managed runtime roots such as
154+
state-local `tmp/`. Recreate those artifacts after restore.
155+
156+
Verify before extracting, then stage the archive in a private temporary
157+
directory:
158+
159+
```bash
160+
set -euo pipefail
161+
162+
ARCHIVE=./2026-03-09T08-00-00.000+08-00-openclaw-backup.tar.gz
163+
164+
openclaw backup verify "$ARCHIVE"
165+
166+
restore_dir="$(mktemp -d -t openclaw-restore.XXXXXX)"
167+
trap 'rm -rf "$restore_dir"' EXIT
168+
169+
tar -xzf "$ARCHIVE" -C "$restore_dir"
170+
manifest_path="$(find "$restore_dir" -mindepth 2 -maxdepth 2 -name manifest.json -print -quit)"
171+
test -n "$manifest_path"
172+
cat "$manifest_path"
173+
```
174+
175+
Treat the staging directory as sensitive. It can contain credentials, auth
176+
profiles, sessions, and workspace data. The `trap` removes it when the shell
177+
exits.
178+
179+
The manifest records `archiveRoot`, the original paths under `paths`, and an
180+
`assets[]` list. Each asset includes its `kind`, original `sourcePath`, and
181+
`archivePath` inside the tarball. Use those fields as the source of truth; do
182+
not derive the archive root from the archive filename.
183+
184+
The archive layout is:
185+
186+
```text
187+
<archive-root>/manifest.json
188+
<archive-root>/payload/posix/<absolute-source-path-without-leading-slash>/...
189+
<archive-root>/payload/windows/<DRIVE>/<rest>/...
190+
<archive-root>/payload/relative/<relative-source-path>/...
191+
```
192+
193+
Before copying files back, stop the Gateway and any node hosts that use them.
194+
Make a fresh backup of the current state or move the current directories
195+
aside. Restore the smallest set of assets needed.
196+
197+
For example, this restores the state asset to the current user's default
198+
state directory. The target stays absent until `cp -a` creates it, preserving
199+
the staged directory's mode and metadata:
200+
201+
```bash
202+
set -euo pipefail
203+
204+
state_archive_path="$(
205+
node -e 'const fs = require("node:fs"); const manifest = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); process.stdout.write(manifest.assets.find((asset) => asset.kind === "state")?.archivePath ?? "");' "$manifest_path"
206+
)"
207+
test -n "$state_archive_path"
208+
209+
state_source="$restore_dir/$state_archive_path"
210+
state_target="$HOME/.openclaw"
211+
state_backup="$HOME/.openclaw.pre-restore.$(date +%s)"
212+
213+
test -d "$state_source"
214+
openclaw gateway stop
215+
216+
if [ -e "$state_target" ] || [ -L "$state_target" ]; then
217+
mv "$state_target" "$state_backup"
218+
fi
219+
test ! -e "$state_target"
220+
test ! -L "$state_target"
221+
cp -a "$state_source" "$state_target"
222+
223+
openclaw doctor
224+
openclaw gateway start
225+
openclaw health
226+
openclaw status
227+
```
228+
229+
For a same-machine restore, the manifest `sourcePath` values are usually the
230+
intended targets. On a new machine or under a different home directory,
231+
choose the new targets first, then copy only the matching asset payloads.
232+
Typical full-restore targets are the state directory, active config file,
233+
credentials directory, and workspace directories. See
234+
[Updating](/install/updating#rollback) for the rollback workflow.
235+
236+
### Restore a database
237+
238+
For a snapshot, `openclaw backup sqlite restore <snapshot-directory> --target
239+
<new-database-path>` writes a re-verified database to a fresh target. For
240+
Litestream, `litestream restore` writes a fresh database file. Move either
241+
result into place while the Gateway is stopped, then start the Gateway and
242+
check `openclaw health` and `openclaw doctor`.
156243

157244
After restoring onto a different OpenClaw version, preflight the database
158245
first with `openclaw database preflight`; see

0 commit comments

Comments
 (0)