Skip to content

WIP: daily D1 backups to R2 (Workflow) - #2

Merged
devandrepascoa merged 16 commits into
cloudflare-workersfrom
add-backups
Oct 12, 2026
Merged

devandrepascoa merged 16 commits into
cloudflare-workersfrom
add-backups

Conversation

@devandrepascoa

Copy link
Copy Markdown
Owner

Stacked on #1 (base is add-tests, so the diff shows only the backup work).

What

  • BackupWorkflow (splitpro-backup, daily 03:00 UTC): starts a D1 REST export, polls until the signed URL is ready, streams the .sql dump into the splitpro-backups R2 bucket, then prunes dumps older than BACKUP_RETENTION_DAYS (default 90).
  • Each step retries; failures go to Workers Logs via logError.
  • wrangler.example.jsonc and README: bucket, workflow, vars, restore steps.
  • D1 Time Travel (30 days) is already on and needs no setup. These dumps are for longer retention.

Setup done on production (not in git)

  • R2 bucket splitpro-backups
  • Worker secret D1_EXPORT_TOKEN: account-scoped API token with D1 Write (the export endpoint returns "Authentication error" for D1 Read)
  • Deployed as version 6dc6f84a

Status: draft, not fully verified

  • Verified: step 1 (start export) succeeds, and the polling request is accepted after fixing a missing output_format.
  • Not yet verified: a finished run with a dump in R2. At last check the second step was still polling ("Export not ready yet") after about 1 minute for a 217 kB database.
  • Not covered: no automated test for the workflow, and no restore drill yet.

Follow-ups

  • Two unused read-only tokens named splitpro-d1-export* were created while finding the right permission. They need deleting in the dashboard (the CLI session cannot delete tokens).

@devandrepascoa

Copy link
Copy Markdown
Owner Author

retry

@devandrepascoa

Copy link
Copy Markdown
Owner Author

retry preview

@devandrepascoa

Copy link
Copy Markdown
Owner Author

rerun preview

@github-actions

Copy link
Copy Markdown

🚀 Worker preview: https://pr-2-splitpro.andrepascoa.workers.dev

@devandrepascoa
devandrepascoa changed the base branch from add-tests to cloudflare-workers October 11, 2026 23:56
@devandrepascoa
devandrepascoa marked this pull request as ready for review October 12, 2026 00:09
@devandrepascoa
devandrepascoa merged commit 4fc6bfc into cloudflare-workers Oct 12, 2026
5 checks passed
@devandrepascoa
devandrepascoa deleted the add-backups branch October 12, 2026 00:19
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