# Updating Swarmica
## General Information

Updating the system can follow one of three scenarios:

1. **Automatic, skipping intermediate versions** is possible when there are **no changes to startup files** (docker-compose.yml, .env, etc.) and **no changes to the data schema** that delete any data.
2. **Automatic, cannot skip intermediate version** is used when there are **no changes to startup files** (docker-compose.yml, .env, etc.), but **there are changes to the data schema** that delete any data. Intermediate updates are necessary to preserve this data for further use. From the perspective of the system administrator performing the update, no additional actions are required; automation will perform all necessary actions, but the update time will increase, and there will be an additional restart on the intermediate version.
3. **Manual** is possible when **there are changes to startup files** (docker-compose.yml, .env, etc.) and it is necessary to read the instructions for updating and perform all the actions listed there.

## Performing the Update

The update is performed from the installation directory (`/root/swarmica`):

```
make upgrade-plan    # show the update plan without making changes
make upgrade         # perform the update
```

1. `cd /root/swarmica`
2. `make upgrade-plan` downloads the update manifest and builds a plan to the latest release. It is recommended to run this command first to estimate the update duration and the planned number of actions.
3. `make upgrade` downloads the update manifest, builds a plan to the latest release, and executes it step by step.

![](https://support.swarmica.com/attachments/B/9/B9_gjw6VieKEvR5-_a/Swarmica_Autoupdate_Schema.png)

Each step: checks, downloading images, backing up the database, writing versions to `.env`, starting containers with waiting for migrations, `post_start`. Anything that can fail is done before changing `.env`: if there is a failure at this stage, nothing changes. If a step прерывается after changing `.env`, повторне `make upgrade` will continue from the stopping point, and if there is a failure, exact instructions for rollback are printed.

* For steps requiring manual preparation, the update stops and shows a link to the instructions. After preparation and completing all steps from the instructions: `make upgrade ACK=vX.Y.Z`.
* Automatic update is available only from a release version. If `.env` specifies `main` or `devel`, specify the actual release: `make set-release VERSION=vX.Y.Z`, then `make pull up`.
  The version can be found in the system interface in the **Settings** section; if you have difficulties, contact Swarmica support.

## System Requirements

1. Swarmica version not lower than [v6.0.0](https://support.swarmica.com/article/ru/1765) – it must be updated manually according to the instructions of intermediate versions.
2. Updating requires Docker Compose not lower than 2.24.6, GNU make 4.x, jq 1.6 and later, curl, and flock.

## Transition to Auto-update

1. Download the latest installer archive to the server with Swarmica:

  `wget https://support.swarmica.com/attachments/installer/installer.tar.gz`
2. Extract the archive:

  `tar -xvzf installer.tar.gz templates/Makefile`
3. Copy the Makefile to the directory where Swarmica is installed:

  `cp templates/Makefile /root/swarmica/`
4. Check that you have the `SW_RELEASE_VERSION` variable in `/root/swarmica/.env`, and if it is not there, add it with the version installed on the server (you can view it in the **Settings** section).