# Snapshots

:::caution[Preview]
Snapshots are new and have not yet been tested end to end. Details may change.
:::

A snapshot is a copy of your VPS's whole disk: the system, installed software and `/home`. Take
one before a risky change, such as a database migration or a big upgrade, and roll back to it if
the change goes wrong.

## Take a snapshot

```sh
lt vps snapshot create dev before-migrate
```

The VPS can be running or stopped. A running VPS keeps running; its disk pauses for a moment
while the copy is cut. The command waits until the snapshot is ready. Without a name, it is
called `snap-<date>-<time>`.

A snapshot is taken as if the VPS lost power at that moment: RAM and running processes are not
saved. Programs that keep data in memory, such as a database, recover the way they do after a
power cut. To be sure, stop such programs, or the whole VPS, before you take the snapshot.

## List and delete snapshots

```sh
lt vps snapshot ls dev
lt vps snapshot rm dev before-migrate
```

## Roll back

```sh
lt vps stop VPS_ID --yes --wait
lt vps restore dev before-migrate
lt vps start VPS_ID
```

The VPS must be stopped. Restoring replaces the disk with the snapshot, and the disk's current
state is not kept: take another snapshot first if you may want to come back to it. The snapshot
itself stays, so you can roll back to it again. The next Start boots the snapshot's disk.

The dashboard has the same actions in the Snapshots section of a VPS.

## Limits

- At most 10 snapshots per VPS.
- A snapshot is deleted after 30 days, or after `--expires-in-days N` (1 to 90).
- A deleted VPS keeps its snapshots until it is purged (at the end of its restore period, or at once with `lt vps delete --now`); the purge deletes them.
- Snapshots are kept on the same storage as the VPS's disk. They protect you from your own
  mistakes, not from losing that storage: copy important data elsewhere too.
- Snapshots are not billed separately today.