time_travel
Creates, updates, deletes, gets or lists a time_travel resource.
Overview
| Name | time_travel |
| Type | Resource |
| Id | cloudflare.d1.time_travel |
Fields
The following fields are returned by SELECT queries:
- list
Bookmark retrieved successfully
| Name | Datatype | Description |
|---|---|---|
bookmark | string | A bookmark representing a specific state of the database at a specific point in time. (example: 00000001-00000002-00004e2f-0a83ea2fceebc654de0640c422be4653) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | account_id, database_id | timestamp | Retrieves the current bookmark, or the nearest bookmark at or before a provided timestamp. Bookmarks can be used with the restore endpoint to revert the database to a previous point in time. |
restore | exec | account_id, database_id | bookmark, timestamp | Restores a D1 database to a previous point in time either via a bookmark or a timestamp. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
database_id | string | The D1 database ID. |
bookmark | string | A bookmark to restore the database to. Required if timestamp is not provided. |
timestamp | string (date-time) | An ISO 8601 timestamp to restore the database to. Required if bookmark is not provided. |
SELECT examples
- list
Retrieves the current bookmark, or the nearest bookmark at or before a provided timestamp. Bookmarks can be used with the restore endpoint to revert the database to a previous point in time.
SELECT
bookmark
FROM cloudflare.d1.time_travel
WHERE account_id = '{{ account_id }}' -- required
AND database_id = '{{ database_id }}' -- required
AND timestamp = '{{ timestamp }}'
;
Lifecycle Methods
- restore
Restores a D1 database to a previous point in time either via a bookmark or a timestamp.
EXEC cloudflare.d1.time_travel.restore
@account_id='{{ account_id }}' --required,
@database_id='{{ database_id }}' --required,
@bookmark='{{ bookmark }}',
@timestamp='{{ timestamp }}'
;