# Upgrading HEAVY.AI

This section is giving a recipe to upgrade between fully compatible products version.

{% hint style="warning" %}
As with any software upgrade, **it is important that you back up your data before upgrading.** Each release introduces efficiencies that are not necessarily compatible with earlier releases of the platform. HeavyAI is never expected to be backward compatible.

Back up the contents of your $HEAVYAI\_STORAGE directory.
{% endhint %}

### Upgrading from Omnisci

If you need to upgrade from Omnisci to HEAVY.AI 6.0 or later, please refer to the specific recipe.

{% content-ref url="upgrading-omnisci-1" %}
[upgrading-omnisci-1](https://docs.heavy.ai/installation-and-configuration/installation/upgrading-omnisci/upgrading-omnisci-1)
{% endcontent-ref %}

{% hint style="danger" %}
Direct upgrades from Omnisci to HEAVY.AI version later than 6.0 aren't allowed nor supported.
{% endhint %}

## Upgrading Using Docker

To upgrade HEAVY.AI in place in Docker

In a terminal window, get the Docker container ID.

```bash
sudo docker container ps --format "{{.Id}} {{.Image}}" \
-f status=running | grep omnisci\/
```

You should see output similar to the following. The first entry is the container ID. In this example, it is `9e01e520c30c`:

```bash
9e01e520c30c omnisci/omnisci-ee-gpu
```

Stop the HEAVY.AI Docker container. For example:

```bash
docker container stop 9e01e520c30c
```

Optionally, remove the HEAVY.AI Docker container. This removes unused Docker containers on your system and saves disk space.

```bash
docker container rm 9e01e520c30c
```

Backup the Omnisci data directory (typically `/var/lib/omnisci`)

```bash
tar zcvf /backup_dir/omnisci_storage_backup.tar.gz /var/lib/omnisci
```

Download the latest version of the HEAVY.AI Docker image according to the Edition and device you are actually coming from\
Select the tab depending on the Edition (**Enterprise**, **Free**, or **Open Source**) and execution Device (**GPU** or **CPU**) you are upgrading.

{% tabs %}
{% tab title="EE GPU" %}

```bash
sudo docker run -d --gpus=all \
  -v /var/lib/heavyai:/var/lib/heavyai \
  -p 6273-6278:6273-6278 \
  heavyai/heavyai-ee-cuda:latest
```

{% endtab %}

{% tab title="EE CPU" %}

```bash
sudo docker run -d -v \
/var/lib/heavyai:/var/lib/heavyai \
-p 6273-6278:6273-6278 \
heavyai/heavyai-ee-cpu:latest
```

{% endtab %}

{% tab title="OS GPU" %}

```bash
sudo docker run -d --gpu=all \
  -v /var/lib/heavyai:/var/lib/heavyai \
  -p 6273-6278:6273-6278 \
  heavyai/core-os-cuda:latest
```

{% endtab %}

{% tab title="OS CPU" %}

```bash
sudo docker run -d -v \
/var/lib/heavyai:/var/lib/heavyai \
-p 6273-6278:6273-6278 \
heavyai/core-os-cpu:latest
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If you don't want to upgrade to the latest version but want to upgrade to a specific version, change the`latest`tag with the version needed.

If the version needed is the 6.0 use v6.0.0 as the version tag in the image name

`heavyai/heavyai-ee-cuda:v6.0.0`
{% endhint %}

Check that the docker is up and running a `docker ps commnd:`

```bash
sudo docker container ps --format "{{.Image}} {{.Status}}" \
-f status=running | grep heavyai\/
```

You should see an output similar to the following.

```bash
heavyai/heavyai-ee-cuda Up 48 seconds ago 
```

This runs both the HEAVY.AI database and Immerse in the same container.

{% hint style="info" %}
You can optionally add `--rm` to the Docker `run` command so that the container is removed when it is stopped.
{% endhint %}

See also the note regarding the [CUDA JIT Cache](https://github.com/omnisci/docs-internal/tree/cf4f376a0cb17fad74ce72feb807d39858156c5b/installation-and-configuration/installation/upgrading-omnisci/4_performance.html#jit-cache) in Optimizing Performance.

## Upgrading HEAVY.AI Using Package Managers and Tarball

To upgrade an existing system installed with package managers or tarball.\
The commands upgrade HEAVY.AI in place without disturbing your configuration or stored data

Stop the HEAVY.AI services.

```bash
sudo systemctl stop heavydb heavy_web_server
```

Back up your $HEAVYAI\_STORAGE directory (the default location is `/var/lib/heavyai`).

Run the appropriate set of commands depending on the method used to install the previous version of the software.

{% tabs %}
{% tab title="YUM" %}

```bash
sudo yum update heavyai.x86_64
```

{% endtab %}

{% tab title="APT" %}

```bash
sudo apt update
sudo apt upgrade heavyai
```

{% endtab %}

{% tab title="Tarball" %}
Make a backup of your actual installation

```bash
sudo mv /opt/heavyai /opt/heavyai_backup
```

Download and Install the latest version following the install documentation for your Operative System\
[CentOS/RHEL](https://docs.heavy.ai/installation-and-configuration/installing-on-ubuntu/centos-yum-gpu-ee#installing-with-a-tarball) and [Ubuntu](https://docs.heavy.ai/installation-and-configuration/installing-on-ubuntu/centos-yum-gpu-ee#installing-with-a-tarball)
{% endtab %}
{% endtabs %}

When the upgrade is complete, start the HEAVY.AI services.

```bash
sudo systemctl start heavydb heavy_web_server
```
