Request a demo

Glossary · BigQuery

What is time travel and fail-safe?

Time travel lets you query or restore BigQuery data as it was at any point in the last 2 to 7 days (7 by default, set per dataset). Fail-safe keeps deleted data 7 more days for emergency recovery through Google support. Both are billed only under physical storage billing.

Also called: BigQuery time travel, FOR SYSTEM_TIME AS OF, fail-safe, max_time_travel_hours, undelete table

How time travel works

BigQuery never edits storage blocks in place. A change writes new versions of the affected blocks and keeps the old ones for the time travel window, so you can:

  • query a table as of a past moment with FOR SYSTEM_TIME AS OF;
  • restore a deleted, expired or overwritten table by copying it from a past timestamp;
  • see what a table looked like before a bad load or MERGE, which is often the fastest way to scope a data incident.
-- The orders table as it was one hour ago
SELECT order_id, status
FROM analytics.orders
  FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR);

-- Keep 2 days of time travel instead of 7 for this dataset
ALTER SCHEMA analytics SET OPTIONS (max_time_travel_hours = 48);

The window is a dataset option, max_time_travel_hours, in multiples of 24 from 48 to 168 (2 to 7 days); 168 is the default, and a project-level default can also be set. A deleted table keeps the window that was in effect when it was deleted. A timestamp outside the window fails with an Invalid snapshot time error.

Fail-safe

After time travel ends, deleted and replaced data spends another 7 days in fail-safe. You cannot query it or shorten it. Recovery needs Cloud Customer Care to grant temporary access, after which you restore the table yourself with a copy job; large tables can take several attempts, so ask early in the 7 days.

What it does to the bill

Under the default logical storage billing, time travel and fail-safe cost nothing extra. Under physical billing, both are charged at the active physical rate, $0.04 per GiB-month in the US multi-region.

The cost is driven by churn, not by table size. Changing one cell rewrites the whole block that holds it, so small updates can send much more than the change to time travel. A 1 TiB (physical) table replaced in full every day keeps, in steady state, about 7 old copies in time travel and 7 in fail-safe: up to 14 TiB, or about $573 a month. With a 2-day window it is 9 TiB; the 5 TiB saved is about $205 a month.

INFORMATION_SCHEMA.TABLE_STORAGE reports both, deleted tables included:

SELECT
  table_schema AS dataset,
  table_name,
  deleted,
  ROUND(time_travel_physical_bytes / POW(1024, 3), 1) AS time_travel_gib,
  ROUND(fail_safe_physical_bytes / POW(1024, 3), 1) AS fail_safe_gib,
  ROUND((time_travel_physical_bytes + fail_safe_physical_bytes)
    / POW(1024, 3) * 0.04, 2) AS usd_month_if_physical
FROM `region-us`.INFORMATION_SCHEMA.TABLE_STORAGE
WHERE time_travel_physical_bytes + fail_safe_physical_bytes > 0
ORDER BY usd_month_if_physical DESC
LIMIT 20;

The dollar column applies only to datasets on physical billing.

Pitfalls

  • Restore by copy job (bq cp with a time decorator): copies are free. A CREATE TABLE AS SELECT ... FOR SYSTEM_TIME AS OF is billed as a query.
  • A restored table does not get the original partitioning or tags. Recreate the partition spec first if you need it.
  • Time travel does not restore table metadata and does not cover external tables or temporary tables.
  • For retention longer than 7 days, take table snapshots; time travel is not a backup.

FAQ

How do I restore a deleted BigQuery table?

Within the time travel window, copy it from a point in time when it existed: bq cp mydataset.orders@1795327200000 mydataset.orders_restored restores it as of 2026-11-22 06:00:00 UTC (the number is milliseconds since the Unix epoch). You cannot query a deleted table directly, even with FOR SYSTEM_TIME AS OF.

Can I recover data after the time travel window?

For 7 more days, from fail-safe, but not by yourself: Cloud Customer Care has to grant fail-safe recovery access on the dataset, and then you restore the table with a copy job. After fail-safe ends, the data is gone.

Can I restore a single partition with time travel?

No. You can only restore an entire table, from a timestamp before the partition was deleted or expired. Copying with a partition decorator and a time decorator together is not supported.

Read next

Browse the full glossary

Cut BigQuery spend without guessing

Masthead attributes compute and storage cost to every project, user, pipeline and table, finds unused and dead-end tables, and shows where editions or on-demand pricing is cheaper. Mnemonic cut its BigQuery compute cost by 20% within 24 hours of onboarding.