Schedule logo
Cloudflare D1 logo
Cloudflare R2 logo

Workflow template

Archive a daily D1 SQL export in R2

Export database schema and data as SQL and save a dated copy in the selected R2 bucket.

How it works

Archive a daily D1 SQL export in R2

1 Trigger · 2 Actions
Schedule1 · Trigger

Daily schedule

Run automatically on the configured schedule.

Cloudflare D12 · Action

Export the database as SQL

Wait for the database export and return its SQL file for a storage step. Use the bookmark action for larger exports.

Cloudflare R23 · Action

Archive the SQL file

Run the R2 S3-compatible PutObject operation.

Before activation

Set up your workflow

  1. Select the source database

    Connect D1, then select the database in “Export the database as SQL”. This step includes schema and data and returns an inline SQL file up to 5 MiB.

  2. Choose an archive bucket

    Connect R2 with write access to your archive bucket. Keep File mapped to the export step. The object key starts with d1-archives/ and includes the scheduled time so you can identify each backup.

  3. Set the backup window

    Choose a quiet daily window. Cloudflare pauses queries to the source database during an export. Check the timezone before activating the schedule.

  4. Verify a restore

    After a run, download the .sql object from R2. Import it into a separate, empty D1 database. Query a table for a known row and compare its ID and value with the source.

Explore connected apps