---
title: Versions and restore
description: Every publish is an immutable version of a site; list a site's versions, make an older one live again and choose how many are kept.
---

Every `pols publish` to a site makes a new version and makes it live at once. A version never changes: publishing again adds a version rather than changing the live one, so you can always go back to one the site still keeps.

```sh
pols sites get my-docs          # the site and its versions, newest first, the live one marked
pols sites restore my-docs 2    # make version 2 live again
pols sites set my-docs --keep 3 # keep the newest 3 versions (and the live one)
```

Versions are numbered from 1 for each site. `pols sites get` shows each version's number, its files and size, where it came from (the sandbox and directory) and when it was published.

## Restore a version

`pols sites restore SITE VERSION` (`POST /v1/sites/{site}/versions/{version}/restore`) makes a kept version live again, by its number or its ID (`ver_...`). Visitors get it on their next request. Restoring makes no new version, and the versions newer than the restored one stay kept, so you can switch forward again the same way.

Restoring works because the files stay with pols: it does not need the sandbox the version came from, which may since have been stopped or deleted.

## How many versions are kept

A site keeps its newest versions, 10 by default, and always the live one, also when you restored an older one. Change the number with `pols sites set SITE --keep N` (`keep_versions`), from 1 to 100. A publish that makes a site hold more drops its oldest versions that are not live; lowering the number drops the versions beyond it at once. A dropped version cannot be restored.

Kept versions count towards your org's [site storage](/docs/publish/sites/#limits) and [disk billing](/docs/publish/sites/#billing), but a file that is the same in several versions of a site is stored and counted once. Publishing a small change to a large site therefore adds little.
