# Backups and restore

BitHut saves the data of every project, so you can go back when something is lost or broken. This page explains when copies are made, how long they are kept and how to put data back.

## When BitHut saves the data

- **Before every new version.** Just before a deploy, BitHut saves the project disk and the database.
- **Before a database copy.** When a database from another service is copied in, the project's database is saved first.
- **Every night.** A nightly copy of the disk and the database, on every plan.

Some nightly copies are kept in another place. Putting data back from one of them takes a few minutes longer, because BitHut downloads it first.

## How long nightly copies are kept

| Plan | Nightly copies |
|---|---|
| Start | the last 7 days |
| Plus | the last 7 days, and one a week for 4 weeks |
| Pro | the last 7 days, one a week for 4 weeks, and one a month for 6 months |
| Max | the last 7 days, one a week for 4 weeks, and one a month for 12 months |

The copies made before each version do not depend on the plan.

## Putting data back in the cabinet

1. Open the project. On its overview, the card "Data is saved every night" has the button "Put data back".
2. You see the saved points, newest first, with their time in UTC and what they are: "Before a new version" or "Nightly copy".
3. If the project has a database, choose "Project files" or "Database" at the top.
4. Press "Put back" next to the point you want, and confirm.

You can also ask your AI: "My data from yesterday is gone, put it back". The AI lists the points and asks you to confirm the time before it restores.

## What happens during a restore

- **Project files.** The project stops for a moment, `/data` goes back to the chosen point, and the project starts again. Everything saved after that time is replaced. The code and settings do not change.
- **Database.** The project and its database stop for about a minute. The database goes back to the chosen point, then both start again. Files in `/data` and the code do not change.
- A paused project stays paused after the restore.
- If the restore fails, the data does not change and you see that it failed.

## A restore can be undone

The state just before the restore is kept for at least 7 days. If you picked the wrong point, write to team@bithut.app and BitHut support can bring it back.

For your AI: `list_restore_points`, `restore_data`, with `what=database` for the database.
