← Back
Cloudflare
Cloudflare Sandbox SDK adds backup and restore API for persistent environments

New Backup and Restore API

Cloudflare Sandbox introduces createBackup() and restoreBackup() methods for persisting and restoring sandbox environments. This feature addresses a common pain point: initial setup tasks like cloning repositories and installing dependencies can take minutes, making it impractical to repeat these steps every time a user resumes work.

Key Capabilities

The backup and restore API provides:

  • Persist and reuse across sessions — Store backup handles in KV, D1, or Durable Object storage for retrieval in future sessions
  • Multi-instance forking — Deploy a single backup across many sandboxes to enable parallel work
  • Named backups — Assign human-readable labels for easier management
  • Automatic cleanup — Configure TTLs to automatically remove backups after they're no longer needed

Storage and Configuration

Backups are stored in R2, Cloudflare's object storage service. Developers can leverage R2 object lifecycle rules to control backup retention and prevent indefinite storage costs.

Getting Started

The backup and restore guide provides setup instructions and usage patterns, while the Backups API reference documents all available methods. A typical workflow involves creating a backup after initial setup, storing the handle for later use, then restoring instead of re-running expensive initialization steps.