Skip to content

Conversation

@kn0wn
Copy link

@kn0wn kn0wn commented Jan 31, 2026

Problem

Currently, only /root/.clawdbot/ and /root/clawd/skills/ are synced to R2 for persistence. This means agent workspace files are lost on container restart:

  • memory/ (agent memory/notes)
  • TOOLS.md (local tool configuration)
  • tov/ (tone of voice docs)
  • Any other custom directories the agent creates

This is particularly painful for agents that rely on persistent memory across sessions.

Solution

Add the full workspace (/root/clawd/) to the R2 sync:

sync.ts:

  • Added rsync for /root/clawd/R2/clawd/
  • Excludes .git, node_modules, and temp files

start-moltbot.sh:

  • Added restore logic for workspace from R2/clawd/
  • Workspace restore runs before the legacy skills restore

Backwards Compatibility

The legacy /skills/ path is preserved for backwards compatibility with existing R2 backups that only have the skills directory.

Testing

  1. Deploy with this change
  2. Create files in /root/clawd/ (e.g., memory/test.md)
  3. Wait for sync (5 min cron) or trigger manually
  4. Restart container
  5. Verify files are restored

Fixes agent memory loss on container restart.

Previously, only /root/.clawdbot/ and /root/clawd/skills/ were synced
to R2 for persistence. This meant agent workspace files like memory/,
TOOLS.md, and other custom directories were lost on container restart.

Changes:
- sync.ts: Add rsync for /root/clawd/ -> R2/clawd/
- start-moltbot.sh: Add restore for workspace from R2/clawd/

The legacy /skills/ path is preserved for backwards compatibility
with existing backups.

Fixes agent memory loss on container restart.
@kn0wn
Copy link
Author

kn0wn commented Feb 1, 2026

#102

leppert pushed a commit to leppert/moltworker that referenced this pull request Feb 1, 2026
Expand R2 persistence to include the entire /root/clawd/ workspace
directory with selective exclusions (.git, node_modules, temp files).

This ensures memory logs, tool configurations, and custom directories
are preserved across container restarts.

Persisted paths:
- /root/.clawdbot/ -> R2/clawdbot/ (config, cron, credentials)
- /root/clawd/ -> R2/clawd/ (workspace: memory, tools, custom files)
- /root/clawd/skills/ -> R2/skills/ (legacy path for backwards compat)

Based on cloudflare#88

https://claude.ai/code/session_017APBZwhNzm4or2KTSxzoAd
leppert pushed a commit to leppert/moltworker that referenced this pull request Feb 1, 2026
Expand R2 persistence to include the entire /root/clawd/ workspace
directory with selective exclusions (.git, node_modules, temp files).

This ensures memory logs, tool configurations, and custom directories
are preserved across container restarts.

Persisted paths:
- /root/.clawdbot/ -> R2/clawdbot/ (config, cron, credentials)
- /root/clawd/ -> R2/clawd/ (workspace: memory, tools, custom files)
- /root/clawd/skills/ -> R2/skills/ (legacy path for backwards compat)

Based on cloudflare#88

https://claude.ai/code/session_017APBZwhNzm4or2KTSxzoAd
leppert pushed a commit to leppert/moltworker that referenced this pull request Feb 1, 2026
Expand R2 persistence to cover the entire /root/clawd/ workspace directory,
not just skills. This prevents data loss on container restarts for:
- Agent memory and notes
- Tool configuration files (TOOLS.md)
- Tone of voice documentation
- Custom directories created by agents

Changes:
- sync.ts: Add rsync for /root/clawd/ to R2/clawd/ with exclusions for
  .git, node_modules, and temp files
- start-moltbot.sh: Restore full workspace from R2 before legacy skills restore

Backwards compatible with existing R2 backups that only have skills/.

Based on cloudflare#88

https://claude.ai/code/session_01Ckh9sHzHzPwkNBBPuzAapq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant