Schedule logo
Cloudflare Workers KV logo
Cloudflare R2 logo

Workflow template

Back up a group of KV keys to R2

Export a selected prefix with binary values, metadata and absolute expiry times. Store a dated JSON file in a private R2 bucket.

How it works

Back up a group of KV keys to R2

1 Trigger · 2 Actions
Schedule1 · Trigger

Daily schedule

Run automatically on the configured schedule.

Cloudflare Workers KV2 · Action

Read keys and preserve their expiry

Export matching keys, binary values, metadata and absolute expiry times to a JSON file for restoration.

Cloudflare R23 · Action

Save the dated backup

Run the R2 S3-compatible PutObject operation.

Before activation

Set up your workflow

  1. Choose the keys to include

    Connect Workers KV, choose the source namespace and enter a prefix such as routing:. Use a separate prefix for configuration that must be restored together.

  2. Select the private archive bucket

    Connect R2 and select the backup bucket. Each schedule occurrence produces a distinct JSON object under kv-backups/. Choose a quiet time because a prefix export reads keys over several requests.

  3. Check the archive

    Open a test archive with your R2 connection. Entries include the key and a base64 value, plus metadata and absolute expiration when present. A narrower prefix is needed if the export exceeds 5 MiB or 10,000 keys.

  4. Practice a restore

    Choose a separate empty KV namespace. Skip entries that have expired, write the remaining rows with Write a batch of keys, and compare restored bytes and metadata with the originals.

Explore connected apps