# Roll back a deploy

> Return an app or site to a previous deploy's image without a rebuild

URL: https://pier.run/docs/guides/roll-back-a-deploy

**Goal.** `api` was deployed with a faulty change; the previous deploy is running again
within a minute.

### See the history

```bash
pier deploys ls api
```

```text title="output"
                                                                                        
 STATUS     TYPE RESOURCE ENV  COMMIT  MESSAGE                                  CREATED 
                                                                                        
 succeeded  app  api      prod da2b... fix(configdiff): a volume binding is ... 26s ago 
 superseded app  api      prod         zot.pier-registry.svc.cluster.local:5... 1m ago  
 superseded app  api      prod         zot.pier-registry.svc.cluster.local:5... 2m ago  
 succeeded  app  api      prod da2b... fix(configdiff): a volume binding is ... 3m ago  
                                                                                        

```

Every `pier deploy`, and every push once [GitHub](/docs/guides/deploy-from-github) is
connected, is a row with the image it produced. `pier deploys info <id>` shows the
details and `pier deploys logs <id>` the build log.

### Roll back

```bash
pier rollback api
```

```text title="output"
→  Rolling back to the previous deployment depl_01m1... (1m ago) — pass --to to pick another.
→  Rolling back api...
Status: running
OK  Rolled back api to depl_01m1... (image: registry.pier.run/01a053...)

```

With no `--to`, the previous successful deploy is chosen. The target rolls to that
deploy's image; nothing is rebuilt.

```bash
pier deploys ls api
```

```text title="output"
                                                                                        
 STATUS     TYPE RESOURCE ENV  COMMIT  MESSAGE                                  CREATED 
                                                                                        
 running    app  api      prod         zot.pier-registry.svc.cluster.local:5... 4s ago  
 succeeded  app  api      prod da2b... fix(configdiff): a volume binding is ... 43s ago 
 superseded app  api      prod         zot.pier-registry.svc.cluster.local:5... 2m ago  
 superseded app  api      prod         zot.pier-registry.svc.cluster.local:5... 2m ago  
 succeeded  app  api      prod da2b... fix(configdiff): a volume binding is ... 3m ago  
                                                                                        

```

The rollback is itself a deploy. To roll forward again, run `pier rollback api --to <id>`
with the newer id, or `pier deploy api` once the fix is committed.

## Variations

* **A specific deploy**: `pier rollback api --to <id>` with an id from `pier deploys ls`.
* **A site**: `pier rollback www` returns to the previous published bundle.
* **Variables**: a rollback changes the image, not the environment. If a variable caused
  the problem, reset it with `pier vars set` ([Set environment variables](/docs/guides/set-environment-variables)).

## See also

[`pier rollback`](/docs/cli/reference/rollback) · [`pier deploys`](/docs/cli/reference/deploys) ·
[Deploys](/docs/deploys)
