Skip to content

Part L. If something goes wrong, and retiring the old Worker

The old Worker is not a working fallback today: its database has refused writes because of the daily limit, and it would hit that limit again within a day of real use. So the safety of this plan is not “go back to the Worker”; it is the server’s own recovery (Part J) and a careful, step-by-step cutover (Part H). The levels below are in the order you try them.

Level Problem What you do Time
1 A service misbehaves sudo systemctl restart bideward-hub (or bideward-research, cloudflared-bideward); read sudo journalctl -u <name> -n 100 1 minute
2 A bad release of the hub code sudo bideward-update PREVIOUSTAG (the same command as for an update: maintenance on, checkout, npm ci, restart, health check; an update that fails its health check already rolls itself back and sends a Telegram message; the log is /var/log/bideward-deploy.log). Database changes are forward-only and each one is tested; never undo a table change by hand. If a migration itself is the problem, restore from the last dump (level 3). 5 minutes
3 Data damaged or deleted Settings restore points (J.4 A), a scratch restore of the rows (J.4 B), or a full restore (J.4 C) 15 minutes to 2 hours
4 The server is lost or locked Rebuild on a new Lightsail instance from the dumps (J.4 C), or from a snapshot (J.4 D). Loader addresses and Cloudflare do not change. 1 to 2 hours
5 The migration must be abandoned Only possible if the old Worker can take writes again (its limit resets at 00:00 UTC); re-paste the old loaders. A short-term emergency, not a plan. Hours

If both Tailscale and SSH stop working, the box cannot be reached at all (the firewall allows nothing else, on purpose, and Lightsail has no separate console once the browser terminal is closed). Options are then limited to level 4. That is why the lockout test in A.8 is mandatory and why the Tailscale account must have two-factor and a recovery method.

All of these must be true:

  1. At least 14 days stable on the new server, with the whole cutover finished and every loader and bootstrap re-pasted.
  2. At least one successful monthly restore drill (J.5).
  3. Cloudflare → Workers → titan-stats analytics show no requests for 7 days.
  4. A final export taken from the old Worker’s backup (G.3) is kept offline: a copy on your computer and a copy in Drive.

L.3 How it is retired (each step needs your yes)

Section titled “L.3 How it is retired (each step needs your yes)”
  1. Workers & Pages → titan-stats → Settings → Domains & Routes: turn the workers.dev route off. Wait 7 days. If nothing complains, continue.
  2. Delete the titan-stats Worker. This also deletes its Durable Object data; it cannot be undone, which is why steps L.2 and the offline export come first. I will ask you for the exact word to type before this step.
  3. Remove any Cloudflare API token or secret that belonged to the old Worker (Profile → API Tokens, and the Worker’s own secrets die with it).
  4. Update the CLAUDE.md of both repositories: the receiver is the Lightsail hub at app.bideward.com and api.bideward.com; the old Worker is gone.

The migration is complete, and this document gets its DONE mark, when every line below is true. I will tick them with you one by one.

Item Done when
Adapter Branches 1 to 3 merged; E.7 all passed
Server Parts A, B, F finished; the security checklist (Part N) is all green
Cloudflare Parts D finished; tunnel Healthy; WAF, rate limit, Access in place
Data Part G finished; zero differences
Cutover Part H finished; all loaders re-pasted; first day reviewed
Speed Part I table all green at 3 bots
Backups Part J: first dump, Drive copy, one restore drill passed
Monitoring Part K: external monitor, Lightsail alarms, failure hook, bideward-watch all tested once
Worker retired L.2 and L.3 done
Docs Doc 65 shows the migration items as moved to this document and closed; doc 55 carries the final status; this document’s status line reads DONE with the date

← Previous: Part K. Monitoring and alerts · Guide index · Next: Part M. Troubleshooting →