-
Notifications
You must be signed in to change notification settings - Fork 2
Time Travel
D1 Manager provides visibility into Cloudflare D1's Time Travel feature, helping you understand database state and providing CLI guidance for point-in-time recovery.
D1 Time Travel allows point-in-time recovery for any D1 database. While restore operations require the Wrangler CLI, D1 Manager provides:
- Current bookmark visibility - See your database's current state identifier
- Checkpoint history - Track bookmarks captured before destructive operations
- CLI command generation - Copy-ready Wrangler commands for restore operations
- Manual checkpoints - Create snapshots at any point in time
- Select a database from the database list
- Click the Time Travel tab in the database view
- View current bookmark, retention info, and checkpoint history
The current bookmark represents your database's exact state at this moment. Bookmarks are:
- Lexicographically sortable - Later bookmarks sort after earlier ones
- Deterministic - Derived from timestamps
- Unique identifiers - Each bookmark points to a specific database state
Click the Copy button next to the bookmark to copy it to your clipboard for use with Wrangler CLI.
D1 Manager generates ready-to-use Wrangler CLI commands:
wrangler d1 time-travel restore my-database --bookmark=00000085-0000024c-00004c6d-8e611177d83f7fb2f0396d0847be2cc62eaa94debb2f65eae0a58c44c4cf6a74wrangler d1 time-travel info my-databaseClick Copy to copy the command, then run it in your terminal.
Time Travel retention depends on your Cloudflare plan:
| Plan | Retention Period |
|---|---|
| Free | 7 days |
| Paid | 30 days |
Note: Bookmarks older than your retention period cannot be used for restore operations.
D1 Manager automatically captures bookmarks before destructive operations:
| Operation Type | When Captured |
|---|---|
pre_drop_table |
Before DROP TABLE |
pre_drop_column |
Before DROP COLUMN |
pre_delete_rows |
Before DELETE operations |
manual |
User-initiated checkpoint |
The checkpoint history shows:
- Bookmark - The captured state identifier
- Operation - What triggered the capture
- Description - Context about the operation
- Captured At - When the bookmark was saved
- User - Who performed the operation
- Find the checkpoint you want to restore to
- Click Copy to copy the restore command
- Run the command in your terminal with Wrangler
Create a checkpoint at any time:
- Click Create Checkpoint in the Time Travel panel
- Optionally add a description
- The current bookmark is saved to your checkpoint history
Remove old checkpoints:
- Expand the checkpoint entry
- Click Delete
- Confirm the deletion
Note: Deleting a checkpoint only removes the saved record. The actual database state remains recoverable via Time Travel until the retention period expires.
D1 Manager automatically captures checkpoints before:
Before dropping any table, a checkpoint is captured with:
- Table name
- Timestamp
- User email
Before dropping a column, a checkpoint is captured with:
- Table and column name
- Timestamp
- User email
Before deleting rows (via the UI), a checkpoint is captured with:
- Table name
- WHERE clause used
- Timestamp
- User email
GET /api/time-travel/:dbId/bookmarkResponse:
{
"success": true,
"result": {
"bookmark": "00000085-0000024c-...",
"capturedAt": "2025-11-27T10:30:00.000Z",
"databaseId": "uuid-...",
"databaseName": "my-database",
"restoreCommand": "wrangler d1 time-travel restore my-database --bookmark=..."
}
}GET /api/time-travel/:dbId/history?limit=50Response:
{
"success": true,
"result": [
{
"id": 1,
"database_id": "uuid-...",
"database_name": "my-database",
"bookmark": "00000085-...",
"operation_type": "pre_drop_table",
"description": "Before dropping table: users",
"captured_at": "2025-11-27T10:00:00.000Z",
"user_email": "[email protected]",
"restoreCommand": "wrangler d1 time-travel restore my-database --bookmark=..."
}
]
}POST /api/time-travel/:dbId/capture
Content-Type: application/jsonBody:
{
"description": "Before schema changes"
}Response:
{
"success": true,
"result": {
"bookmark": "00000085-...",
"capturedAt": "2025-11-27T10:30:00.000Z",
"databaseId": "uuid-...",
"databaseName": "my-database",
"restoreCommand": "wrangler d1 time-travel restore my-database --bookmark=..."
}
}DELETE /api/time-travel/:dbId/history/:idResponse:
{
"success": true,
"deleted": true
}Checkpoint history is stored in the bookmark_history table:
CREATE TABLE IF NOT EXISTS bookmark_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
database_id TEXT NOT NULL,
database_name TEXT,
bookmark TEXT NOT NULL,
operation_type TEXT NOT NULL,
description TEXT,
captured_at DATETIME DEFAULT CURRENT_TIMESTAMP,
user_email TEXT
);- Create a manual checkpoint before significant schema changes
- Add a descriptive note about what you're about to do
- Keep the checkpoint ID/bookmark for reference
For critical databases, consider creating regular checkpoints:
- Before deployments
- Before bulk data imports
- Before schema migrations
Periodically review and delete old checkpoints:
- Remove checkpoints for operations that completed successfully
- Keep checkpoints for major changes or incidents
- Note: Actual database states are available via Time Travel regardless of saved checkpoints
Time Travel restore operations require the Wrangler CLI:
wrangler d1 time-travel restore my-database --bookmark=<bookmark>There is no REST API for restore operations - this is a Cloudflare D1 limitation.
- Bookmarks expire after the retention period (7/30 days)
- Expired bookmarks cannot be used for restore
- Plan accordingly for disaster recovery
Time Travel works with all D1 databases, including those with FTS5 virtual tables.
- Verify the database exists and you have access
- Check API token permissions (D1 Edit required)
- Ensure the database is not empty
- The bookmark is older than your retention period
- Use a more recent checkpoint if available
- Consider upgrading to a Paid plan for 30-day retention
- Verify the bookmark format is correct
- Ensure you have Wrangler CLI installed and authenticated
- Check the database name matches exactly
- Undo Rollback - Restore dropped tables, columns, and deleted rows
- Database Management - Database operations
- Job History - Track bulk operations
- Cloudflare D1 Time Travel Docs
Need Help? See Troubleshooting or open an issue.
- Database Management
- R2 Backup Restore
- Scheduled Backups
- Table Operations
- Query Console
- Schema Designer
- Column Management
- Bulk Operations
- Job History
- Time Travel
- Read Replication
- Undo Rollback
- Foreign Key Visualizer
- ER Diagram
- Foreign Key Dependencies
- Foreign Key Navigation
- Circular Dependency Detector
- Cascade Impact Simulator
- AI Search
- FTS5 Full Text Search
- Cross Database Search
- Index Analyzer
- Database Comparison
- Database Optimization