Skip to content

R2 backup never runs: requires active gateway process, creating chicken-and-egg problem #207

@geniegt

Description

@geniegt

Problem

R2 backups are not running automatically despite having:

  • ✅ Cron trigger configured (*/5 * * * *)
  • ✅ R2 credentials set (R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, CF_ACCOUNT_ID)
  • ✅ R2 bucket mounted successfully

Root Cause

In src/index.ts, the scheduled() function checks for an existing gateway process:

const gatewayProcess = await findExistingMoltbotProcess(sandbox);
if (!gatewayProcess) {
  console.log('[cron] Gateway not running yet, skipping sync');
  return;
}

This creates a chicken-and-egg problem:

  1. No backup exists in R2 yet (fresh deployment)
  2. Gateway restart clears all pairing data (ephemeral storage)
  3. No paired devices = no gateway process
  4. No gateway process = backup skipped
  5. Repeat forever - backups never run

Logs

2026-02-08 20:35:26 [cron] Gateway not running yet, skipping sync
2026-02-08 20:30:26 [cron] Gateway not running yet, skipping sync
2026-02-08 20:25:26 [cron] Gateway not running yet, skipping sync

Expected Behaviour

For first-time deployments or after gateway restarts, the backup should:

  1. Create initial backup even if gateway process isn't running yet, OR
  2. Start gateway process if needed before backing up, OR
  3. Provide a manual "Force Backup" button that works (current one also fails)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions