Markdown Converter
Agent skill for markdown-converter
You are an AI assistant running inside a Cloudflare Sandbox container. This document explains how to manage your workspace persistence and R2 storage.
Sign in to like and favorite skills
You are an AI assistant running inside a Cloudflare Sandbox container. This document explains how to manage your workspace persistence and R2 storage.
If the tools don't exist yet, clone them:
# Check if tools exist if [ ! -d "/openclaw-container-tools" ]; then cd / git clone https://github.com/jerryfane/openclaw-container-tools.git chmod +x /openclaw-container-tools/scripts/*.sh echo "Tools installed successfully!" else echo "Tools already exist" fi
To get the latest version:
cd /openclaw-container-tools git pull origin main chmod +x scripts/*.sh echo "Tools updated!"
# Verify tools are available ls -la /openclaw-container-tools/scripts/
You're running in a container that can restart at any time. To preserve your work:
/root/clawd/ should be synced to R2 storage/data/moltbot//openclaw-container-tools/scripts/Note: The sync script automatically detects your workspace location:
/root/clawd/ (OpenClaw/Clawdbot standard location)/workspace/ (if it exists)WORKSPACE_DIR environment variable for custom pathPath:
/openclaw-container-tools/scripts/sync-workspace-to-r2.sh
Purpose: Backs up your entire OpenClaw workspace (
/root/clawd/) to R2, excluding large/unnecessary files like node_modules, .git, __pycache__, etc.
How to use:
# Regular sync /openclaw-container-tools/scripts/sync-workspace-to-r2.sh # Test mode (see what would sync without doing it) DRY_RUN=true /openclaw-container-tools/scripts/sync-workspace-to-r2.sh # DANGEROUS: Enable deletion mode (removes files from R2 that don't exist locally) # Only use this if you really want to clean up R2! DELETE_MODE=true /openclaw-container-tools/scripts/sync-workspace-to-r2.sh
What it does:
/root/clawd/ → /data/moltbot/workspace/Important: Files are only ADDED/UPDATED in R2, never deleted. This protects against data loss on container restart.
Path:
/openclaw-container-tools/scripts/start-moltbot.sh
This runs automatically when the container starts. It:
# Check if R2 mount exists ls -la /data/moltbot/ # Check mount status mount | grep "/data/moltbot" # See what's in R2 ls -la /data/moltbot/workspace/
# Check environment variables env | grep -E "R2_|CF_ACCOUNT"
If missing, R2 won't work. The credentials need to be:
R2_ACCESS_KEY_IDR2_SECRET_ACCESS_KEYCF_ACCOUNT_ID# Add to crontab (syncs every hour) (crontab -l 2>/dev/null; echo "0 * * * * /openclaw-container-tools/scripts/sync-workspace-to-r2.sh >> /var/log/workspace-sync.log 2>&1") | crontab - # Or every 30 minutes (crontab -l 2>/dev/null; echo "*/30 * * * * /openclaw-container-tools/scripts/sync-workspace-to-r2.sh >> /var/log/workspace-sync.log 2>&1") | crontab - # Check if cron is set crontab -l
# Run sync every 30 minutes in background nohup bash -c 'while true; do /openclaw-container-tools/scripts/sync-workspace-to-r2.sh; sleep 1800; done' > /var/log/sync-loop.log 2>&1 & # Check if running ps aux | grep sync-workspace
Just run the sync when you've made important changes:
/openclaw-container-tools/scripts/sync-workspace-to-r2.sh
If you need to restore workspace from R2:
# Check what's in R2 ls -la /data/moltbot/workspace/ # Restore everything to OpenClaw workspace (CAREFUL - overwrites local) rsync -av /data/moltbot/workspace/ /root/clawd/ # Restore specific directory rsync -av /data/moltbot/workspace/myproject/ /root/clawd/myproject/ # Custom workspace location WORKSPACE_DIR=/custom/path rsync -av /data/moltbot/workspace/ $WORKSPACE_DIR/
R2 isn't mounted. Check:
env | grep R2_mount | grep s3fsThe script has a 10GB safety limit. If needed:
MAX_SIZE_GB=20Check if you have files:
ls -la /root/clawd/ find /root/clawd -type f | head -20 # Or check detected workspace /openclaw-container-tools/scripts/sync-workspace-to-r2.sh | head -5
# Last sync time cat /data/moltbot/workspace/.last-sync # Sync completed marker cat /data/moltbot/workspace/.sync-complete
The sync script ignores:
No automatic deletion: Files are NEVER deleted from R2 by default (safety feature)
DELETE_MODE=true only when you want to clean up R2Safety: Script won't sync more than 10GB by default
Persistence: After container restart, restore your workspace from R2
Workspace Detection: Script auto-detects
/root/clawd/ (OpenClaw) or /workspace/
# Sync now (safe - only adds/updates, never deletes) /openclaw-container-tools/scripts/sync-workspace-to-r2.sh # Test sync (dry run) DRY_RUN=true /openclaw-container-tools/scripts/sync-workspace-to-r2.sh # Clean up R2 (DANGEROUS - removes files not in local) DELETE_MODE=true /openclaw-container-tools/scripts/sync-workspace-to-r2.sh # Set up hourly sync (crontab -l 2>/dev/null; echo "0 * * * * /openclaw-container-tools/scripts/sync-workspace-to-r2.sh") | crontab - # Check R2 contents ls -la /data/moltbot/workspace/ # Restore from R2 rsync -av /data/moltbot/workspace/ /root/clawd/ # Check last sync cat /data/moltbot/workspace/.last-sync
When working on projects:
/root/clawd/ (your OpenClaw workspace)Safety First: The sync script will NEVER delete files from R2 unless you explicitly use
DELETE_MODE=true. This means:
Remember: Container can restart anytime. Sync important work frequently!