Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Time Travel and Fail-safe

Snowflake, BigQuery & Databricks · Snowflake

Time Travel and Fail-safe

Easywarehouses-06
snowflaketime-travelfail-saferecovery

Question

What are Time Travel and Fail-safe in Snowflake?

Solution

Time Travel lets you query, clone or restore data as it was at an earlier point, within a retention period. Fail-safe is a further seven days after that, where only Snowflake support can recover the data, and it is meant for disaster recovery rather than daily use.

Time Travel

SELECT * FROM orders AT (TIMESTAMP => '2025-03-01 09:00:00'::timestamp);
SELECT * FROM orders BEFORE (STATEMENT => '01b2c3d4-...');   -- before a bad query

CREATE TABLE orders_restored CLONE orders AT (OFFSET => -3600);  -- 1 hour ago
UNDROP TABLE orders;                                             -- bring back a dropped table

The default retention is 1 day. On Enterprise edition and above, you can set it up to 90 days for permanent tables. It works because micro-partitions are immutable: an update writes new files and keeps the old ones until the retention window passes.

A typical save: someone runs DELETE FROM orders without a WHERE. You find the statement id in the query history and create a clone from just before it, or restore the data from that point.

Fail-safe

After Time Travel expires, permanent tables have a 7-day Fail-safe. You cannot query it. Only Snowflake support can recover data from it, and there is no guarantee about how long it takes. Do not plan around it as a backup.

Cost

Both use storage. Changed or deleted data is kept for the retention period plus the fail-safe, and you pay for it. A table that is rewritten heavily every day with 90 days retention can store many times its visible size.

Transient and temporary tables

These have no Fail-safe, and a Time Travel of at most 1 day. They are cheaper for staging or rebuildable data, which is why they are often used for intermediate layers.

Interview-friendly summary: Time Travel is a self-service window you set (1 to 90 days), Fail-safe is a last-resort 7 days run by Snowflake, and you pay storage for both.

PreviousNext