---
title: "How to Use Databricks Time Travel for Delta Lake Recovery"
description: "Databricks' time travel feature allows users to recover earlier versions of a Delta Lake table, enabling corrections of incorrect data while adhering to retention policies."
url: https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/
date: 2024-04-18
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/pexels-photo-6002000.jpeg?fit=1880%2C1214&ssl=1
categories: ["databricks"]
tags: ["Databricks Delta Time travel", "Versioning in Databricks"]
type: post
lang: en
---

# How to Use Databricks Time Travel for Delta Lake Recovery

To illustrate, you write incorrect data to a [Delta Lake](https://srinimf.com/2025/11/08/exploring-the-latest-delta-lake-features-in-databricks/) table in Databricks. Using Time travel you can correct it. Time travel lets you access earlier versions of a Delta table. This makes it possible to revert to a point before the incorrect data was written.

![Databricks Delta Time travel](https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/pexels-photo-6238608.jpeg?resize=1880%2C1255&ssl=1)*Photo by Max Vakhtbovycn on Pexels.com*

Table of contents

1. [Databricks Time Travel: Recover a Delta Lake Table](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/#databricks-time-travel-recover-a-delta-lake-table)
   1. [Choose the Correct Version](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/#choose-the-correct-version)
   2. [Restoring the Table](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/#restoring-the-table)
   3. [Verify the Data](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/#verify-the-data)

## **Databricks Time Travel: Recover a Delta Lake Table**

Here are the commands that show how the Time travel technique works.

### **Choose the Correct Version**

First, choose the version of the Delta Lake table that holds the correct data. You can view the history of changes to a Delta table using the `DESCRIBE HISTORY` command in Databricks.

```
DESCRIBE HISTORY EMP
```

This command displays a list of all Delta table versions, including timestamps and actions taken.

![Describe](https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/image-3.png?resize=1158%2C406&ssl=1)

### **Restoring the Table**

Select the appropriate version by checking all timestamps. Use the RESTORE command to recover data from that version.

```
RESTORE EMP TO VERSION AS OF 2
```

![RESTORE](https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/image-5.png?resize=1195%2C254&ssl=1)

### **Verify the Data**

Finally, after restoring the table, verify that the correct data has been recovered by querying the table.

```
SELECT * FROM EMP
```

Finally, check the recovered data to ensure it matches your previous data.

![Verify the data](https://i0.wp.com/srinimf.com/wp-content/uploads/2024/04/image-6.png?resize=1146%2C390&ssl=1)

Conclusion

Using Delta Lake’s time travel feature, you can go back to an earlier version of a Delta table and restore it to a state without the wrong data. However, keep in mind that retention policies can lead to the automatic deletion of older versions. **It’s crucial to recover the table quickly** before the version you need is gone.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2024%2F04%2F18%2Fdatabricks-time-travel-tutorial-on-recovering-delta-tables%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2024%2F04%2Fpexels-photo-6002000.jpeg%3Ffit%3D1200%252C775%26ssl%3D1&description=How%20to%20Use%20Databricks%20Time%20Travel%20for%20Delta%20Lake%20Recovery)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2024/04/18/databricks-time-travel-tutorial-on-recovering-delta-tables/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Use%20Databricks%20Time%20Travel%20for%20Delta%20Lake%20Recovery&body=https%3A%2F%2Fsrinimf.com%2F2024%2F04%2F18%2Fdatabricks-time-travel-tutorial-on-recovering-delta-tables%2F&share=email)
-

### Like this:

Like Loading…
