---
title: luna restore
description: Rewind one luna, every luna of a type or a whole environment to an earlier moment.
related:
  - /develop/restore-to-an-earlier-moment
  - /cli/fork
---

`luna restore` puts lunas back as they were at a moment in the past: one luna, every luna of a type or every luna of the environment.

```bash
luna restore List --key '{"id":"groceries"}' --to "1h ago"
```

## Reference

```bash
luna restore [OPTIONS] --to <TO> [LUNA_TYPE]
```

| Option | Type | Default | Does |
| --- | --- | --- | --- |
| `[LUNA_TYPE]` | text | Every type | Restores only the lunas of this type. |
| `--key <KEY>` | JSON | None | Restores only the luna with this key, such as `'{"id":"a"}'`. Needs a type. |
| `--to <TO>` | moment | Required | The [moment](/cli#moments) to go back to. It must be in the past. |
| `--limit <LIMIT>` | number | `64` | How many lunas each request to Luna restores, at most 1000. |
| `--yes` | flag | Off | Restores without asking first. |
| `--dir <DIR>` | path | `.` | The app's folder. Its env file names the project and environment. |
| `--env <ENV>` | text | `LUNA_ENV`, then `production` | The environment. |
| `--project <PROJECT>` | text | `LUNA_PROJECT` | The project, by name or as `organisation/project`. |
| `--tenant <TENANT>` | text | The environment's own | A tenant added to the environment, by name. |
| `--token <TOKEN>` | text | `LUNA_TOKEN`, then your login | An API token or account key to act with. |

:::warning
Everything the restored lunas wrote after that moment is lost. To keep the present data, copy the luna first with [`luna fork`](/cli/fork) or [`luna export`](/cli/export).
:::

## Good to know

- The CLI asks before it restores. Without a terminal, pass `--yes`, or the command changes nothing and ends with exit code `6`.
- A luna that did not exist yet at that moment is left as it is. The CLI counts these apart from the lunas it restored.
- The CLI restores page after page until every luna is done. A luna that fails is named with its error, and the command ends with exit code `1`. Run it again for those.

## Examples

### Rewind one luna

```bash
luna restore List --key '{"id":"groceries"}' --to "1h ago"
```

### Rewind every luna of a type to a time

```bash
luna restore List --to 2026-11-09T10:00:00Z
```

### Rewind a whole environment from a script

```bash
luna restore --env staging --to "30m ago" --yes
```
