# Upgrade

> The Flexter upgrade process.

---

Site [llms.txt](/flexter/v2.1/llms.txt)

---

## Upgrade the License

If the license is about to expire, it can be upgraded by replacing the `flexter.lic` file, as described in the [Post Installation](/flexter/v2.1/docs/installation/direct-installation/post-installation/#license-setup) section.

Replace the license file where it exists in one of these paths:

```text
# For all users
/etc/flexter/conf/flexter.lic

# For the current user
~/.config/flexter/flexter.lic

# same directory that you are launching a flexter command
./flexter.lic
```

## Repository Packages Upgrade

If the [Repository Setup](/flexter/v2.1/docs/installation/direct-installation/download/#repository-setup) was done before, you can upgrade through it.

### YUM/DNF Repository

#### Upgrading to the latest version

```bash
sudo dnf --repo=sonra-flexter update xml2er xsd2er json2er merge2er flexchma flexter-ui
```

#### Upgrading to the specific version

```bash
sudo dnf --repo=sonra-flexter update xml2er-2.1.2 xsd2er-2.1.2 json2er-2.1.2 merge2er-2.1.2 flexchma-2.1.2 flexter-ui-2.1.2
```

### APT Repository

The apt repository might be disabled by default. If it's the case, you would need to re-enable it before the upgrade.

#### Enabling the Repository (optional)

<details>

<summary><b>Show the full list</b></summary>

To re-enable it, rename the `/etc/apt/sources.list.d/sonra-flexter.list.disabled` and remove the `.disabled` extension:

```bash
sudo mv /etc/apt/sources.list.d/sonra-flexter.list{.disabled,}
```

</details>

#### Upgrading

##### Upgrading to the latest version

```bash
sudo apt update
sudo apt upgrade xml2er xsd2er json2er merge2er flexchma flexter-ui
```

##### Upgrading to the specific version

```bash
sudo apt update
sudo apt upgrade xml2er=2.1.2 xsd2er=2.1.2 json2er=2.1.2 merge2er=2.1.2 flexchma=2.1.2 flexter-ui=2.1.2
```

If the repository was re-enabled, we recommend disabling it again after the upgrade to avoid unwanted upgrades, e.g. when the server administrator wants to upgrade the server packages, not Flexter itself.

#### Disabling the Repository (optional)

<details>

<summary><b>Show the full list</b></summary>

To disable it, rename the `/etc/apt/sources.list.d/sonra-flexter.list` and add the `.disabled` extension:

```bash
sudo mv /etc/apt/sources.list.d/sonra-flexter.list{,.disabled}
```

</details>

## Manual Packages Upgrade

In cases where the repository hasn't been set up, the packages can be downloaded directly and upgraded manually as the procedures below.

Make sure the `curl` or `wget` command is available. 
All examples are based on curl, but you can use `wget` instead.

```bash
# curl approach
curl -u "<USER>:<PASS>" -OL <URL>

# wget approach
wget --user "<USER>" --password "<PASS>" <URL>
```

### URL pattern

```text
https://download.sonra.io/flexter/<MODULE>[-VERSION].<EXTENSION>
```

### Redhat-Based

Example of Redhat-Based distributions:
* Red Hat Enterprise Linux (RHEL)
* CentOS Stream
* Rocky Linux
* AlmaLinux
* Fedora
* Oracle Linux
* Amazon Linux

#### Download installers

You can download the latest installers or specific versions as the pattern `<MODULE>[-VERSION].rpm`

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.rpm
```

#### Checking hash (optional)

<details>

<summary><b>Show the full list</b></summary>

Checking if the files were downloaded correctly with the md5 hash algorithm.

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.rpm.md5

# helper function
md5ck() { md5sum -c <(echo `cat $1.md5` $1); }

md5ck flexchma*.rpm
md5ck xml2er*.rpm
md5ck xsd2er*.rpm
md5ck json2er*.rpm
md5ck merge2er*.rpm
md5ck flexter-ui*.rpm
```

</details>

#### Upgrading the packages

```bash
sudo dnf install xml2er*.rpm xsd2er*.rpm json2er*.rpm merge2er*.rpm flexchma*.rpm flexter-ui*.rpm
```

### Debian-Based

Example of Debian-Based distributions:
* Debian
* Ubuntu
* Linux Mint
* MX Linux
* Kali Linux
* Raspberry Pi OS
* Pop!_OS

#### Download installers

You can download the latest installers or specific versions as the pattern `<MODULE>[-VERSION].deb`

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.deb
```

#### Checking hash (optional)

<details>

<summary><b>Show the full list</b></summary>

Checking if the files were downloaded correctly with the md5 hash algorithm.

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.deb.md5

# helper function
md5ck() { md5sum -c <(echo `cat $1.md5` $1); }

md5ck flexchma*.deb
md5ck xml2er*.deb
md5ck xsd2er*.deb
md5ck json2er*.deb
md5ck merge2er*.deb
md5ck flexter-ui*.deb
```

</details>

#### Installing the packages

```bash
sudo apt install xml2er*.deb xsd2er*.deb json2er*.deb merge2er*.deb flexchma*.deb flexter-ui*.deb
```

### Unix-Based

For the other type of distros, not compatible with Redhat-Based or Debian-Based, the `.tgz` packages can be downloaded and installed manually:

Examples of other Unix-Based distributions:
* Mac OS
* Alpine Linux
* Arch Linux
* Gentoo
* OpenBSD
* FreeBSD
* NetBSD
* Solaris
* OpenSolaris
* OpenIndiana

#### Download installers

You can download the latest installers or specific versions as the pattern `<MODULE>[-VERSION].tgz`

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.tgz
```

#### Checking hash (optional)

<details>

<summary><b>Show the full list</b></summary>

Checking if the files were downloaded correctly with the md5 hash algorithm.

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.tgz.md5

# helper function

md5ck() { md5sum -c <(echo `cat $1.md5` $1); }

md5ck flexchma*.tgz
md5ck xml2er*.tgz
md5ck xsd2er*.tgz
md5ck json2er*.tgz
md5ck merge2er*.tgz
md5ck flexter-ui*.tgz
```

</details>

#### Upgrading the packages - with root access

Move old packages to a backup folder

```bash
sudo mv /usr/share/flexter /usr/share/flexter_$(date --iso-8601)
```

Then, the next procedures are similar to the installation.

```bash
# flexchma
sudo tar xzf flexchma*.tgz -C /usr/share

# xml2er
sudo tar xzf xml2er*.tgz -C /usr/share

# xsd2er
sudo tar xzf xsd2er*.tgz -C /usr/share

# json2er
sudo tar xzf json2er*.tgz -C /usr/share

# merge2er
sudo tar xzf merge2er*.tgz -C /usr/share

# flexter-ui
sudo mkdir -p /usr/share/flexter/flexter-ui
sudo tar xzf flexter-ui*.tgz -C /usr/share/flexter/flexter-ui
```

#### Upgrading the packages - without root access

```bash
mv ~/.local/share/flexter ~/.local/share/flexter_$(date --iso-8601)
```

Then, repeat the same procedures as the installation

```bash
# flexchma
tar xzf flexchma*.tgz -C ~/.local/share

# xml2er
tar xzf xml2er*.tgz -C ~/.local/share

# xsd2er
tar xzf xsd2er*.tgz -C ~/.local/share

# json2er
tar xzf json2er*.tgz -C ~/.local/share

# merge2er
tar xzf merge2er*.tgz -C ~/.local/share

# flexter-ui
mkdir -p ~/.local/share/flexter/flexter-ui
tar xzf flexter-ui*.tgz -C ~/.local/share/flexter/flexter-ui
```

## Post Upgrade

A few extra procedures are needed to complete the upgrade.

### Upgrading the Database

```bash
# For all users
flexchma update

# or with parameters
flexchma update -m "jdbc:postgresql:[<host>[:port]/]<db>" -M <user> -w <password>
```

### Upgrading the Apache Spark

If Apache Spark was installed with the `download.sh` module, it can be upgraded using the script as below:

#### With root access
```bash
sudo /usr/share/flexter/sbin/download.sh spark
```

#### without root access

```bash
~/.local/share/flexter/sbin/download.sh spark
```

More details at the [Post Installation](/flexter/v2.1/docs/installation/direct-installation/post-installation/#installing-the-apache-spark) section.

### Restarting flexter-ui

After the upgrade, the services might require to be restarted to take effect.

#### flexterui-backend

```bash
sudo systemctl restart flexterui-backend
```

#### flexterui-frontend

Optional, if the `env.json` is set in the production mode

```bash
sudo systemctl restart flexterui-frontend
```
