# Roll back and undeploy

> Point a target back at the version it ran before, or at any earlier version, with mk rollback, and end a target's deployment with mk undeploy.

Every version you upload stays in the network. Rolling back is deploying an earlier one again. Undeploying ends a deployment, and the version stays to deploy later.

## List versions

```sh
mk versions list
```

It shows the 50 newest versions of your targets' networks, with the selectors that run each. `mk deployments list` shows each deployment with the version it ran before.

## Roll back

```sh
mk rollback --target prod
```

`mk rollback` points the target back at the version it ran before. Rolling back twice goes forward again. To go back further, name the version:

```sh
mk rollback 5d2e7b18f0a1 --target prod
```

The id as `mk versions list` prints it is enough, for any version of the network, however old. Should another version share those 12 characters, `mk` says so: `mk versions list --full` prints whole ids. The servers swap back while players stay connected. With only one target, `--target` is not needed. Like `mk deploy`, `mk rollback` first lists the servers that run another [platform version](https://minekube.com/games/concepts/platform-version) than the version it goes back to was built for; `--strict-versions` refuses then.

## Undeploy

```sh
mk undeploy canary
```

`mk undeploy` ends the target's deployment. The servers its selector picked stop those bundles and keep what other deployments give them. The version stays in the network, to deploy again with `mk versions deploy`.

The deployment's history goes with it. From then on, also once you deploy to the target again, `mk rollback` without a version has nothing before to go back to: name the version, as `mk undeploy` prints it.

## Related

- [Deploy a version](https://minekube.com/games/versions-and-deployments/deploy)
- [CLI reference](https://minekube.com/games/reference/cli#mk-rollback)
