---
title: How to recover from corrupt state
description: Canonical makes open source secure, reliable and easy to use, providing
  support for Ubuntu and a portfolio of enterprise-grade technologies. Founded in
  2004, Canonical operates globally with team members in over 80 countries.
url: https://canonical.com/dqlite/docs/howto/recover-from-corrupt-state?format=md
---

*Submit*

# How to recover from corrupt state

This guide shows you how to roll back your cluster to the last valid data state following a corruption.

## [Steps](https://canonical.com/dqlite/docs/howto/recover-from-corrupt-state?format=md#p-629-steps)

1. Type and run `dqlite-utils --dir /path/to/dqlite/dir`. You will see the `dqlite-utils` repl start.
2. Type and run the `.open` command. You will see the *open* shell at the ‘latest’ data version.
3. The *open* shell supports arbitrary SQL. Inspect the data to identify the corruption.
4. Use the `.set-index` command to travel back in time to log entry before the corruption occurred. See [how to check data-integrity](https://canonical.com/dqlite/docs/howto/check-data-integrity).
5. [Create a backup a dqlite cluster](https://canonical.com/dqlite/docs/howto/backup-a-dqlite-cluster) of the valid data.
6. [Create a snapshot](https://canonical.com/dqlite/docs/howto/create-a-snapshot) containing the backup.
7. Restart your cluster starting from the just-created snapshot.

You will now see your cluster operating normally, starting on the data immediately before the corruption.

---

[Previous

Inspect raft node status](https://canonical.com/dqlite/docs/howto/inspect-raft-node-status)
[Next

Explanation:
Architecture](https://canonical.com/dqlite/docs/explanation/architecture)

Last updated 2 months ago. [Help improve this document in the forum](https://discourse.dqlite.io/t/how-to-recover-from-corrupt-state/562).
