# Updating

URL: https://docs.vaultpanel.net/getting-started/updating

> Update VaultPanel to a new release with a backup taken first, roll back a bad update, and keep agents on other servers current.

VaultPanel is installed as the `vaultpanel` package from VaultPanel's APT repository, so updates are package upgrades. Each one backs the panel up first, so you can roll back.

## Update the panel

```bash
sudo vaultpanel update                   # the newest version
sudo vaultpanel update --version v0.3.0  # a given version
```

`vaultpanel update` installs the newer `vaultpanel` package with apt:

1. Before the package changes version, it backs the panel up (database, settings and certificate, labelled `pre-update`; the last 3 are kept) and notes the version it had.
2. After installing, it updates the panel's database and restarts the panel and worker.

When there is nothing newer, it says so and stops. `--force` sets the same version up again. It refuses to install a version older than the one installed; use `vaultpanel rollback` for that.

`sudo apt upgrade` updates VaultPanel the same way, along with the system's other packages.

The panel's own agent is updated together with the panel. See the [changelog](https://docs.vaultpanel.net/changelog) for what each release changes.

## Roll back an update

If an update goes wrong:

```bash
sudo vaultpanel rollback
```

It puts back the database from the backup taken just before the last update, then installs the version from before it again. Changes made in the panel since that update are lost, so it asks you to type `rollback` first (`--yes` skips the question).

The package repository keeps the newest 5 versions, so a rollback works only while the earlier version is still there.

> **Warning:**
If no backup from before the update is found, the database stays as it is. When the newer version changed the database, the older one may not start: restore a [panel backup](https://docs.vaultpanel.net/getting-started/backing-up-the-panel) from before the update instead.

## Agents on other servers

The agent on the panel's own server is updated with the panel. When a release brings a newer agent, each other server's **Overview** tab shows **Agent update available**:

- Agents from v0.7.0 on can be updated from the panel: click **Update agent**. The agent downloads the new version from the panel, checks it and restarts itself. To update several servers at once, use **Infrastructure > Bulk Actions** (see [server groups](https://docs.vaultpanel.net/guides/servers/server-groups)).
- Older agents show an **Upgrade command** to run once on the server. It updates the agent in place and keeps its registration.

## A panel installed from a copy of the repository

A panel [installed from a copy of the repository](https://docs.vaultpanel.net/getting-started/installation#install-from-a-copy-of-the-repository) has no package. It updates from that copy instead:

```bash
sudo vaultpanel update                   # the newest release tag
sudo vaultpanel update --branch main     # the newest commit of a branch
```

`vaultpanel update` fetches the newest release tag (or the branch it follows), backs up, and builds it on the server; `vaultpanel rollback` goes back to the commit it had. Or update the copy and run its installer again:

```bash
git -C VaultPanel pull
sudo bash VaultPanel/install.sh
```
