Skip to main content

time_travel

Creates, updates, deletes, gets or lists a time_travel resource.

Overview

Nametime_travel
TypeResource
Idcloudflare.d1.time_travel

Fields

The following fields are returned by SELECT queries:

Bookmark retrieved successfully

NameDatatypeDescription
bookmarkstringA 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:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectaccount_id, database_idtimestampRetrieves 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.
restoreexecaccount_id, database_idbookmark, timestampRestores 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.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
database_idstringThe D1 database ID.
bookmarkstringA bookmark to restore the database to. Required if timestamp is not provided.
timestampstring (date-time)An ISO 8601 timestamp to restore the database to. Required if bookmark is not provided.

SELECT examples

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

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 }}'
;