Time Travel, Fail-Safe & Zero-Copy Cloning
Architecture Diagram 1: Time Travel Data Flow
Architecture Diagram 2: Zero-Copy Cloning Process
Architecture Diagram 3: Time Travel Retention Timeline
Architecture Diagram 4: Zero-Copy Clone Mechanics
Architecture Diagram 5: Data Recovery Workflow
Time Travel enables querying historical data at any point within a configurable retention period (1β90 days on Enterprise Edition). Snowflake maintains micro-partition versioning, allowing point-in-time queries via AT/OFFSET/BEFORE clauses without restoring from backups.
Zero-Copy Cloning creates a complete copy of a table, schema, or database by referencing the same micro-partitions β no data is physically duplicated. A copy-on-write mechanism diverges only modified micro-partitions, consuming storage proportional to actual changes.
Fail-Safe is an automatic 7-day immutable retention period after Time Travel expires. Data in Fail-Safe is read-only, accessible only through Snowflake Support for disaster recovery. It cannot be queried or modified by users.
Theorem: A zero-copy clone is logically equivalent to a full copy at the moment of creation. Proof sketch: Both clone and full copy reference identical micro-partitions. The clone's metadata points to the same physical data blocks. Copy-on-write ensures divergence only occurs when either source or clone is modified, creating new micro-partitions for changed data while keeping unmodified data shared.
Consistency guarantee: A Time Travel query at timestamp T returns the exact state of the table as it existed at T, including all committed transactions before T. Uncommitted transactions at T are invisible. This follows snapshot isolation semantics β each Time Travel query sees a consistent snapshot.
Clone before DDL changes for instant rollback. Use Time Travel for data auditing and regulatory compliance. Combine cloning + Time Travel for development environments with production data fidelity.
- Time Travel provides point-in-time queries (1β90 days retention)
- Zero-Copy Cloning uses copy-on-write β storage cost only for diverged data
- Fail-Safe adds 7 days immutable retention after Time Travel expires
- Clone operations are O(1) metadata β near-instantaneous regardless of table size
- Recovery options: UNDROP β Time Travel β Clone β Fail-Safe (in order of preference)
Detailed Explanation
What is Time Travel?
Time Travel enables querying historical data at any point within a configurable retention period (1β90 days on Enterprise Edition). It leverages micro-partition versioning, not separate backups.
How Time Travel Works
- Modified/deleted data is not immediately overwritten
- New micro-partition versions are created while old versions are retained
- Metadata pointers track current and historical versions
- AT/OFFSET/BEFORE clauses reconstruct table state at the requested time
- Optimizer materializes only the specific micro-partitions needed (efficient)
Fail-Safe: Automatic Disaster Recovery
| Aspect | Description |
|---|---|
| Purpose | Disaster recovery after Time Travel expires |
| Retention | Additional 7 days (fixed, non-configurable) |
| Access | Read-only β Snowflake Support only via support ticket |
| Performance | Hours to days for recovery |
| Configuration | Automatic, no user setup required |
- Data transitions to Fail-Safe after Time Travel window expires
- Permanently purged after 7 days in Fail-Safe
- Designed for worst-case scenarios only
Zero-Copy Cloning: Efficient Data Duplication
- Creates complete copies via metadata pointers (no data duplication)
- 1TB table clone: seconds to create, near-zero storage initially
- Copy-on-write mechanism: only diverged micro-partitions are copied
- Clones are fully independent for DML operations
- Inherit Time Travel retention settings from source
Advanced Use Cases
- Data Auditing β Clone before/after regulatory changes for compliance snapshots
- Development Environments β Clone production for realistic dev data without impact
- Data Science β Use Time Travel to reproduce historical training datasets
- Regression Testing β Clone, apply changes, compare original vs. modified
- Data Quality Analysis β Track quality metrics over time via Time Travel
Key Takeaway: Combine cloning + Time Travel for instant rollback, development environments, and regulatory compliance with production data fidelity.
Key Concepts Table
| Feature | Time Travel | Fail-Safe | Zero-Copy Clone |
|---|---|---|---|
| Purpose | Query historical data | Disaster recovery | Create data copies |
| User Access | SQL queries | Support ticket | SQL queries |
| Retention | 0-90 days (configurable) | 7 days (fixed) | Indefinite (with source) |
| Storage Cost | Included in table storage | Included in table storage | Copy-on-write only |
| Performance | Same as current data | Hours to days | Near-instantaneous |
| Retention Setting | Edition Support | Max Window | Use Case |
|---|---|---|---|
| 0 days | All editions | None | Cost optimization |
| 1 day | Standard | 24 hours | Basic recovery |
| 7 days | Enterprise | 168 hours | Regulatory compliance |
| 90 days | Enterprise+ | 2160 hours | Long-term audit |
| Clone Operation | Time Complexity | Space Complexity | Independence |
|---|---|---|---|
| CREATE CLONE | O(1) - metadata | O(1) initially | Full DML independence |
| INSERT to clone | O(1) + data size | O(changed data) | Source unaffected |
| UPDATE in clone | O(1) + row count | O(modified rows) | Source unaffected |
| DELETE from clone | O(1) + row count | O(deleted rows) | Source unaffected |
Code Examples
-- Example 1: Time Travel queries with different syntax
-- Query data as of specific timestamp
SELECT * FROM sales_data
AT (TIMESTAMP => '2024-01-15 10:30:00'::TIMESTAMP_TZ);
-- Query data as of offset from current time (in seconds)
SELECT * FROM sales_data
AT (OFFSET => -3600); -- 1 hour ago
-- Query data before a specific statement
SELECT * FROM sales_data
BEFORE (STATEMENT => '01234567-89ab-cdef-0123-456789abcdef');
-- Example 2: Clone table with Time Travel
CREATE CLONE sales_data_clone
FROM sales_data
AT (TIMESTAMP => '2024-01-15 00:00:00'::TIMESTAMP_TZ);
-- Clone entire schema with specific point-in-time
CREATE SCHEMA analytics_clone
CLONE analytics_prod
AT (OFFSET => -86400); -- 24 hours ago
-- Example 3: Data recovery using Time Travel
-- Step 1: Identify when data was deleted
SELECT * FROM sales_data
AT (TIMESTAMP => '2024-01-15 10:00:00'::TIMESTAMP_TZ)
EXCEPT
SELECT * FROM sales_data
AT (TIMESTAMP => '2024-01-15 11:00:00'::TIMESTAMP_TZ);
-- Step 2: Recover deleted data
CREATE TABLE sales_data_recovered AS
SELECT * FROM sales_data
AT (TIMESTAMP => '2024-01-15 10:30:00'::TIMESTAMP_TZ);
-- Step 3: Merge recovered data back (if needed)
MERGE INTO sales_data t
USING sales_data_recovered s
ON t.id = s.id AND t.date = s.date
WHEN NOT MATCHED THEN
INSERT (id, date, amount, region)
VALUES (s.id, s.date, s.amount, s.region);
-- Example 4: UNDROP operations
-- Restore dropped table
UNDROP TABLE sales_data;
-- Restore dropped schema
UNDROP SCHEMA analytics;
-- Restore dropped database
UNDROP DATABASE warehouse;
-- Example 5: Advanced cloning patterns
-- Clone with explicit warehouse for large operations
CREATE WAREHOUSE clone_wh WAREHOUSE_SIZE = 'xlarge';
USE WAREHOUSE clone_wh;
CREATE CLONE large_fact_table_clone
FROM large_fact_table;
-- Clone with data transformation
CREATE CLONE sales_filtered_clone AS
SELECT * FROM sales_data
WHERE region = 'US'
AND transaction_date >= '2024-01-01';
-- Example 6: Time Travel data analysis
-- Analyze data changes over time
SELECT
'Current' as version,
COUNT(*) as row_count,
SUM(amount) as total_amount
FROM sales_data
UNION ALL
SELECT
'1 hour ago' as version,
COUNT(*) as row_count,
SUM(amount) as total_amount
FROM sales_data AT (OFFSET => -3600)
UNION ALL
SELECT
'1 day ago' as version,
COUNT(*) as row_count,
SUM(amount) as total_amount
FROM sales_data AT (OFFSET => -86400);
-- Example 7: Automated backup cloning
CREATE OR REPLACE PROCEDURE daily_backup()
RETURNS STRING
LANGUAGE SQL
AS
$$
BEGIN
CREATE CLONE sales_backup_
CLONE sales_data;
-- Drop clones older than 7 days
EXECUTE IMMEDIATE '
DROP TABLE IF EXISTS sales_backup_' ||
TO_CHAR(DATEADD(day, -7, CURRENT_DATE()), 'YYYYMMDD');
RETURN 'Backup completed successfully';
END;
$$;
-- Example 8: Compare table versions
-- Find rows added since specific time
SELECT * FROM sales_data
MINUS
SELECT * FROM sales_data AT (OFFSET => -3600);
-- Find rows deleted since specific time
SELECT * FROM sales_data AT (OFFSET => -3600)
MINUS
SELECT * FROM sales_data;
-- Find rows modified since specific time
SELECT id, amount FROM sales_data
EXCEPT
SELECT id, amount FROM sales_data AT (OFFSET => -3600);
Performance Metrics
| Operation | Time Complexity | Storage Impact | Typical Duration |
|---|---|---|---|
| Time Travel Query | O(partitions) | None (uses existing) | 1-30 seconds |
| Zero-Copy Clone | O(1) metadata | Near-zero initially | < 1 second |
| Fail-Safe Recovery | Manual process | Full table copy | 2-24 hours |
| UNDROP Table | O(1) metadata | None | < 1 second |
| Point-in-Time Clone | O(1) metadata | Near-zero initially | < 1 second |
| Time Travel Window | Storage Overhead | Query Performance | Recovery Capability |
|---|---|---|---|
| 1 day | ~5-15% | Same as current | Recent changes |
| 7 days | ~20-40% | Same as current | Weekly recovery |
| 30 days | ~50-100% | Slightly slower | Monthly recovery |
| 90 days | ~100-200% | Moderately slower | Quarterly recovery |
Best Practices
-
Set appropriate retention periods: Use 1 day for cost-sensitive workloads, 7 days for regulatory compliance, and 90 days only when required by specific regulations.
-
Implement automated cloning schedules: Create scheduled tasks that clone critical tables daily, providing additional recovery points beyond Time Travel.
-
Use Time Travel for auditing: Query historical data to track data quality trends, identify when anomalies occurred, and validate regulatory compliance.
-
Clone before schema changes: Always clone tables before DDL operations, enabling instant rollback if changes cause issues.
-
Monitor Time Travel storage: Track historical data growth to optimize retention settings and manage storage costs.
-
Document recovery procedures: Create runbooks for common data recovery scenarios, including Time Travel queries and cloning operations.
-
Test recovery processes: Regularly test Time Travel queries and cloning operations to ensure they work as expected during actual emergencies.
-
Use UNDROP for accidental drops: Prefer UNDROP over Time Travel for recently dropped objects, as it's faster and doesn't require data copying.
-
Leverage clones for development: Create development environments by cloning production schemas, ensuring developers have realistic data without impacting production.
-
Monitor Fail-Safe eligibility: Understand that Fail-Safe only applies to dropped objects, not deleted data, and plan recovery strategies accordingly.
See Also
- Snowflake Architecture β Micro-partition versioning internals
- Access Control β Data masking for cloned environments
- Stored Procedures β Automated recovery procedures
- Snowpipe Ingestion β Data loading patterns
- PySpark Iceberg Tables β Time travel with Iceberg
- Delta Lake Fundamentals β Delta Lake time travel comparison