Snowflake Time Travel: How It Works, What It Costs, and When It Is Not a Backup
Snowflake Time Travel and Fail-safe in practice: retention, UNDROP, cloning at a timestamp, why storage follows churn, and a restore runbook you can test.
By Dinesh ChandraSenior Data and AI Engineer · SnowPro certifiedChanged: Added a Pitfalls section.
- 1.Time Travel is point-in-time query, UNDROP, and clone at a timestamp. It is not a disaster-recovery backup.
- 2.Standard accounts get 1 day; Enterprise can set up to 90 days per object. Fail-safe adds 7 Snowflake-operated days on permanent tables.
- 3.Time Travel storage scales with churn, not table size. A table rewritten nightly can carry many times its size in history.
- 4.Transient tables skip Fail-safe. Right for staging and anything reproducible, wrong for irreplaceable gold.
- 5.Recover into a clone, diff, then insert or swap. Clone before every risky migration.
Table of contents
- The mental model
- History bills on churn, not table size
- Query as of a time
- UNDROP and clones
- Clone before a risky migration
- Retention knobs
- Transient for anything reproducible
- What this costs
- What this is not
- A restore runbook you can actually test
- Streams are not Time Travel
- Who can UNDROP
- Pitfalls
- FAQ
- What this means for your pipelines
Snowflake Time Travel is the feature people quote in interviews and then mis-use in production. It lets you query a table as it existed earlier, undrop objects, and clone from a timestamp. It does not replace backups, cross-region replication, or a tested restore runbook.
I have never regretted having Time Travel. I have twice recovered a production table someone truncated at 4 p.m., and each recovery took under a minute. What I have regretted is leaving retention at a number nobody chose, on tables whose churn made that number expensive.
This post is the mental model, the SQL you will type on a Friday incident, and the cost knobs that stop history from becoming the largest line item.
The mental model
Snowflake does not edit a micro-partition in place. Every INSERT, UPDATE, DELETE, or MERGE writes new files and re-points metadata. Old files stay readable for the Time Travel window, then enter Fail-safe, then disappear.
flowchart LR
write[INSERT / UPDATE / DELETE] --> current[Current table]
current --> tt[Time Travel window]
tt --> fail[Fail-safe 7 days]
fail --> gone[Purged]
That is why Time Travel works and why it costs storage. You are paying to keep previous versions of partitions.
Self-serve recovery lives only in the Time Travel window. After that, Fail-safe is a Support ticket, and only for permanent tables.
Fail-safe is a fixed seven days after Time Travel expires. You cannot query it, you cannot shorten it, and you cannot turn it off on a permanent table. It is meant for disaster, not for the analyst who dropped a table, and you pay for it the entire time.
flowchart TD
incident[Bad DELETE or DROP] --> window{Still inside retention?}
window -->|yes| self[UNDROP or clone AT timestamp]
window -->|no| fs{Permanent table + Fail-safe left?}
fs -->|yes| ticket[Open a Support case]
fs -->|no| gone[Gone, restore from a real backup]
Self-serve vs Support. Draw this on the runbook before Friday.
History bills on churn, not table size
Both history layers grow with how much you rewrite, not with how big
the table is. A 5 TB append-only table with 30-day retention adds
almost nothing, because appended partitions are never retired. A
100 GB table that gets a full INSERT OVERWRITE every night retires
100 GB of partitions daily. At 30 days retention plus 7 days of
Fail-safe, you are paying for roughly 3.7 TB of history for a 100 GB
table.
Nothing is wrong when that shows up on the invoice. Snowflake is faithfully keeping every version the nightly job produced. The fix is retention or the write pattern, not a support case.
Query as of a time
Three forms cover almost every restore:
-- relative offset (seconds)
select *
from analytics.gold.orders
at (offset => -60 * 60 * 2);
-- exact timestamp (respect session timezone)
select *
from analytics.gold.orders
at (timestamp => '2026-08-21 09:00:00'::timestamp_tz);
-- the statement that wrecked the table
select *
from analytics.gold.orders
before (statement => '01b2c3d4-0000-1111-2222-333344445555');
BEFORE (STATEMENT => …) is the right form when someone ran a DELETE
without a WHERE and you have the query ID from the History page.
It is the one I reach for most, because it removes the guesswork about
timestamps. Pull the offending query_id from QUERY_HISTORY, go to
the state immediately before it, and diff. The
query profile guide covers
finding that ID quickly.
Check the session timezone first. A timestamp that looks “local” in the worksheet may not be the timezone the table was written in.
show parameters like 'TIMEZONE';
Count first. Confirm you are looking at the right damage before you clone or UNDROP:
select
(select count(*) from analytics.gold.orders) as now_rows,
(select count(*)
from analytics.gold.orders
at (timestamp => '2026-08-21 09:00:00'::timestamp_tz)) as then_rows;
If then_rows is not what you expected, you have the wrong timestamp
or the wrong table. Stop.
UNDROP and clones
Dropped by mistake:
undrop table analytics.gold.orders;
undrop schema analytics.gold;
undrop database analytics;
UNDROP only works inside the Time Travel window. After that you are in Fail-safe and you are opening a ticket, not running SQL.
Clone at a timestamp when you need a subset, not a full rollback:
create table analytics.gold.orders_fix clone analytics.gold.orders
at (timestamp => '2026-08-21 09:00:00'::timestamp_tz);
-- or the state immediately before the bad statement
create or replace table analytics.gold.orders_fix clone analytics.gold.orders
before (statement => '01b2c3d4-0000-1111-2222-333344445555');
Zero-copy clone means you pay only for pages that diverge after the clone.
Use the clone to INSERT the good rows back, or to swap names after a
review.
-- recover rows deleted after 09:00 without rolling the whole table
insert into analytics.gold.orders
select *
from analytics.gold.orders_fix f
where not exists (
select 1
from analytics.gold.orders o
where o.order_id = f.order_id
);
-- or, after a count and a key diff, swap the whole table atomically
alter table analytics.gold.orders swap with analytics.gold.orders_fix;
Always recover into a new table and compare, rather than restoring in
place. SWAP WITH is atomic and instant, and it keeps a copy of the
damaged state around in case your understanding of the incident was
wrong. It usually is, the first time.
Clones work at schema and database level too, which is how you reproduce a bug against yesterday’s data:
create database analytics_yesterday clone analytics
at (offset => -86400);
A clone stays free only while both sides keep pointing at the same
partitions. The moment either side writes, the changed partitions
diverge and bill as normal storage. A clone also does not carry
future grants, and privileges on child objects are only preserved when
you clone at the database or schema level, which is where
RBAC and cloning intersect badly.
Audit the clone’s grants before anyone touches it. Storage after
writes, RETAINED_FOR_CLONE_BYTES, and CI clones are covered in the
zero-copy clones post.
Clone before a risky migration
The same mechanism is the cheapest rollback plan Snowflake offers. I use it for any change I am not certain about: a schema restructure, a large backfill, a dbt refactor that rewrites a mart, a change to a clustering key on a big table.
-- 1. Clone the target schema. Instant, and it is your rollback.
create schema analytics.gold_premigration clone analytics.gold;
-- 2. Run the migration against the real schema.
-- (Your dbt run, DDL, backfill, whatever it is.)
-- 3. Reconcile against the clone before anyone downstream sees it.
select
(select count(*) from analytics.gold.orders) as new_rows,
(select count(*) from analytics.gold_premigration.orders) as old_rows,
(select sum(amount_cents) from analytics.gold.orders) as new_total,
(select sum(amount_cents) from analytics.gold_premigration.orders) as old_total;
-- 4a. If it went wrong, swap back. Seconds, not hours.
alter table analytics.gold.orders swap with analytics.gold_premigration.orders;
-- 4b. If it went right, drop the clone on a schedule so it stops billing.
drop schema analytics.gold_premigration;
Step 4b is the one teams skip. A pre-migration clone that nobody drops
keeps diverging from the live table and quietly becomes a full second
copy. I set a calendar reminder, and on accounts where this happens
often I add a weekly query for schemas matching %_premigration older
than fourteen days.
Retention knobs
alter table analytics.gold.orders set data_retention_time_in_days = 7;
show parameters like 'DATA_RETENTION_TIME_IN_DAYS'
in table analytics.gold.orders;
Defaults:
| Edition / object | Typical Time Travel | Fail-safe |
|---|---|---|
| Standard | 1 day | 7 days (Snowflake-operated) |
| Enterprise+ | 0 to 90 days per object | 7 days after Time Travel |
| Transient / temporary | Short or none | None |
Transient and temporary tables cannot use Fail-safe. Do not put irreplaceable gold tables on transient storage to “save money.” You are deleting the last recovery path.
Account-level default is not a substitute for setting retention in the same PR that creates the table.
Retention is inherited from account to database to schema to table, with the most specific setting winning. Setting 90 days account-wide because Enterprise allows it is how you end up paying 90 days on scratch tables. Retention is not a quality signal; it is a multiplier on churn. I set it at the schema level so new tables inherit the right number, and I document any compliance-driven value on the table itself so the next person does not “optimize” it:
-- Set at schema level so new tables inherit it.
alter schema raw.marketing set data_retention_time_in_days = 1;
alter schema analytics.gold set data_retention_time_in_days = 7;
-- A compliance table, documented in place.
alter table analytics.gold.payment_events
set data_retention_time_in_days = 90
comment = 'Retention 90d per FIN-2024-11 audit requirement. Do not reduce.';
Two warnings. Reducing retention takes effect immediately and purges history beyond the new window, so you cannot undo it. Confirm nobody is mid-incident and that no compliance requirement names the number before you cut it. And changing a table’s retention does not change Fail-safe, which is fixed for permanent tables.
Transient for anything reproducible
A transient table has no Fail-safe and can have at most 1 day of Time Travel. On high-churn intermediate tables, that is most of the savings available. The rule I use: if you can rebuild it from a source that still exists, it should be transient. Almost everything between raw and gold qualifies.
create transient table analytics.silver.orders_staging (
order_id number,
customer_id number,
ordered_at timestamp_ntz,
amount_cents number
)
data_retention_time_in_days = 1;
-- Whole schemas can be transient, so everything created inside inherits it.
create transient schema analytics.staging
data_retention_time_in_days = 0;
In dbt it is a one-line config:
-- models/silver/orders_staging.sql
{{ config(
materialized = 'table',
transient = true,
post_hook = "alter table {{ this }} set data_retention_time_in_days = 1"
) }}
select ... from {{ ref('raw_orders') }}
dbt creates tables as transient by default in Snowflake, which is correct. I have seen teams override that to permanent “for safety” without realizing they just bought Fail-safe on 400 intermediate models.
What this costs
Historical partitions bill as storage, not as a special Time Travel SKU. Longer retention on a multi-terabyte bronze table is a real invoice.
Practical policy I use:
- Gold / facts: 7 days on Enterprise. Enough to catch a bad dbt run.
- Silver: 3 to 7 days depending on rebuild cost.
- Bronze landing / raw dumps: 1 day, or transient if the source can replay.
- Dev clones: 0 or 1 day. Do not copy prod retention into every sandbox.
- Compliance tables: exactly the number in the requirement, documented in a table comment.
Pair this with the cost guide. Compute and storage are different conversations; Time Travel is storage.
Stop estimating and query it (lagged, account_usage):
select
table_catalog,
table_schema,
table_name,
table_type,
round(active_bytes / power(1024, 3), 1) as active_gb,
round(time_travel_bytes / power(1024, 3), 1) as time_travel_gb,
round(failsafe_bytes / power(1024, 3), 1) as failsafe_gb,
round((time_travel_bytes + failsafe_bytes) / nullif(active_bytes, 0), 2) as retention_multiple
from snowflake.account_usage.table_storage_metrics
where deleted = false
and active_bytes > power(1024, 3) -- ignore anything under 1 GB
order by (time_travel_bytes + failsafe_bytes) desc
limit 30;
retention_multiple is the number to argue about. Under 0.5 is
healthy. Above 3 means the table is being rewritten far more than its
retention setting assumes: shorten retention, make the table
transient, or change the write pattern to something incremental.
If Time Travel storage on a landing table dwarfs the live table, your retention is a habit, not a policy.
Then check what retention is actually set to, because inherited defaults are rarely what anyone intended:
select table_catalog, table_schema, table_name, retention_time
from snowflake.account_usage.tables
where deleted is null
and retention_time > 7
order by retention_time desc, table_name;
Dropped tables still bill. A dropped table keeps its Time Travel and Fail-safe for the full window, so dropping a large table does not reduce your bill today; it reduces it in retention plus seven days.
flowchart LR
live[Live micropartitions] --> bill[Storage invoice]
hist[Time Travel copies] --> bill
fail[Fail-safe copies] --> bill
Three storage piles. Only the first one is “the table.”
What this is not
- Not a backup. A dropped database after Fail-safe is gone. Use replication or account-level recovery for region loss and bad actors.
- Not free. Trim retention on huge staging tables.
- Not forever. After the window,
ATqueries fail. Test the path. - Not a CDC log. Streams are for incremental pipelines. Time Travel is for “what did this table look like.”
- Clones are not backups either. A clone shares partitions with its source and lives in the same account with the same blast radius. It is a point-in-time snapshot with a rollback story, not an independent copy.
A restore runbook you can actually test
Write this down before the incident:
- Identify the object and the last good time (query History, dbt run timestamp, or a known load).
SELECT count(*)at that time vs now. Confirm you are looking at the right damage.- Clone at the timestamp into a
_fixtable. Do not UNDROP prod as the first move if other writers are live. - Diff keys. Review a sample with the owner.
- Insert or swap. Record the query IDs in the incident ticket.
- If Time Travel has expired, page Support for Fail-safe and expect hours, not minutes.
Practice steps 1 to 4 on a disposable table every quarter. A runbook nobody has run is fiction.
Streams are not Time Travel
A stream is a change feed for a pipeline. Time Travel is “what did
this object look like.” Do not use AT inside a daily incremental
model as a substitute for a stream or an incremental key. You will
re-scan history and still miss the CDC contract.
create or replace stream analytics.silver.orders_stream
on table analytics.silver.orders;
Use the stream (or an incremental watermark) for loads. Use Time Travel for incidents and audits.
CREATE TABLE AS at a timestamp is the audit copy when you do
not want a clone you will keep writing:
create table analytics.audit.orders_2026_08_21 as
select *
from analytics.gold.orders
at (timestamp => '2026-08-21 09:00:00'::timestamp_tz);
That is a full copy. You pay storage immediately. Use it for a compliance extract, not for a Friday rollback; the clone is cheaper for that.
Account default is the fallback, not the policy:
show parameters like 'DATA_RETENTION_TIME_IN_DAYS' in account;
If this is 1 and gold tables never set their own value, a bad dbt run on Sunday is gone by Tuesday on Standard.
Who can UNDROP
UNDROP is a privilege. If every analyst can drop and undrop gold,
you do not have a restore story, you have a race. Grant drop on
gold to the role that runs deploys. Document who pages Snowflake
Support when Fail-safe is the only path.
Pitfalls
Treating Time Travel as the backup. It shares the account and the window ends. Add replication or exports for account and region loss.
Inheriting retention nobody chose. A 90-day account default multiplies churn on scratch tables. Set retention per schema in the same PR that creates it.
Cutting retention mid-incident. Reducing it purges history immediately. Confirm no restore or compliance need before you lower the number.
Making gold transient to save storage. You remove Fail-safe, the last recovery path. Keep transient for tables you can rebuild.
UNDROP as the first move on a live table. Writers keep loading
on top of the restore. Clone at the timestamp into a _fix table,
diff, then insert or swap.
FAQ
Can I query Fail-safe with AT?
No. Fail-safe is not self-serve SQL. After Time Travel ends you open
a ticket, and only for permanent tables still inside the Fail-safe
window.
Does a zero-copy clone duplicate Time Travel storage immediately? Not at clone time. You share micropartitions until either side writes. Storage grows as the clone or the source diverges.
Is UNDROP enough if writers are still running?
Usually no. Clone at a timestamp into a _fix table, diff, then
insert or swap. UNDROP as the first move on a live table is how you
fight the next load.
What if the table is transient? You may still have a short Time Travel window. You do not have Fail-safe. That is why gold should not be transient.
Does Time Travel replace cross-region replication? No. Region loss, account compromise, and “we dropped the database eight days ago on Standard” are backup/replication problems.
Does Time Travel slow down queries?
No. Historical partitions are separate files with their own metadata,
and a normal query only reads the current set. Querying AT or
BEFORE a timestamp reads the historical partitions, which performs
similarly to reading current ones.
What is the cheapest way to keep a monthly snapshot? Clone the schema on a schedule and let old clones age out. Because clones only bill for divergence, a monthly clone of a mostly-static table costs a fraction of a full copy. Automate the drop as well as the create, or you will accumulate them.
What this means for your pipelines
Set retention explicitly when you create the table. Gold facts: 7 days is a sane Enterprise default. Bronze: 1 day or transient only if the source can replay. Document who can UNDROP and how you page Snowflake during Fail-safe.
Time Travel is a seatbelt. It is not the airbag, the spare engine, or the other region.
Replication (or client-side exports) is what you use when the account is gone, the region is gone, or someone dropped the database eight days ago on Standard. Write that path down next to the UNDROP steps. If the only restore story is “we have Time Travel,” you have one failure mode you cannot survive.
The cost side is churn discipline. Every full rewrite is a full copy
into retention, so the same
incremental modeling
work that saves compute also saves storage. Mark everything
reproducible as transient, set retention per schema rather than per
account, and put the TABLE_STORAGE_METRICS query into your weekly
cost review so a
retention multiple over 3 gets noticed while it is still small. If
your deploy process for warehouse changes does not include a
clone-and-reconcile step, add it this week.
Senior Data & AI Engineer · SnowPro Core & Gen AI Certified
4+ years building production data platforms on Snowflake, Databricks, AWS, and Azure. I write from hands-on experience with Medallion architectures, dbt, Airflow, PySpark, and Snowflake Cortex AI. Every tutorial on this blog reflects real pipeline decisions, not documentation rewrites.
Read more about the author →