[All Platforms][Sandbox] backup-workspace.sh restore without a timestamp can restore another sandbox's backup
Description
scripts/backup-workspace.sh backup <sandbox> saves to ~/.nemoclaw/backups/<timestamp>/ and doesn't record which sandbox the backup came from (lines 10 and 113). restore <sandbox> with no timestamp picks the newest directory in ~/.nemoclaw/backups/ (line 165), whichever sandbox it belongs to, and uploads it into the sandbox you named.
The usage text says "If no timestamp is given, the most recent backup is used", and docs/manage-sandboxes/transfer-state-manually.mdx says "Restore the most recent backup or a specific timestamp." Both commands take a sandbox name, so I read that as the most recent backup of that sandbox.
Reproduction Steps
- Use an isolated HOME. Stub
bin/nemoclaw.js downloadso each sandbox's files containcontent-from-<sandbox>, and stubopenshellto log uploads. - Run
backup-workspace.sh backup alice, thenbackup-workspace.sh backup bob. - Run
backup-workspace.sh restore alice.
Environment
- macOS 26.5.2 (arm64), Node.js v22.22.3
- NemoClaw
mainat4c44f7cc8; the script is unchanged ond61268122 - The script run directly with bash, using the stubs above
Debug Output
[backup] Backup saved to .../.nemoclaw/backups/20260928-162305/ (8 items) <- alice
[backup] Backup saved to .../.nemoclaw/backups/20260928-162306/ (8 items) <- bob
$ backup-workspace.sh restore alice
[backup] Using most recent backup: 20260928-162306
[backup] Restored 8 items to sandbox 'alice'.
exit=0
uploaded SOUL.md -> alice: content-from-bob
uploaded USER.md -> alice: content-from-bob
uploaded IDENTITY.md -> alice: content-from-bob
Control, with alice's timestamp given explicitly:
$ backup-workspace.sh restore alice 20260928-162305
uploaded SOUL.md -> alice: content-from-aliceLogs
If you have more than one sandbox and run restore <sandbox> as documented, another sandbox's SOUL.md, USER.md, IDENTITY.md, MEMORY.md and memory/ get written over yours, and the script exits 0. The backup directory names don't say which sandbox they belong to, so choosing the right timestamp by hand is guesswork too.
Keeping backups under ~/.nemoclaw/backups/<sandbox>/<timestamp>/, or writing the sandbox name into each backup and having restore consider only matching ones, would fix it. test/scripts/backup-workspace.test.ts only covers a single sandbox, so a two-sandbox case would be worth adding. #3555 and #1431 changed this script for unrelated reasons.
Checklist
- I confirmed this bug is reproducible
- I searched existing issues and this is not a duplicate
Source: NVIDIA/NemoClaw