# Linux

## To update the IES server for Linux, you have to:

1. Disable the Data Protection on the IES.
2. Update the server using the following instruction.
3. Enable Data Protection again.

## Option 1 (using a script)

To update the server, you can use the `update.sh` script, which is located in the IES directory (`/opt/IES` default). You can run it either manually or through the web interface (by clicking on the server version). If an update is available, you will be prompted to update the server using a script. If you have changed the location of the server, the name of the service to run, you can manually update the necessary parameters in the script.

The script has the following command line parameters:

\--dir - path to IES bin directory. Default /opt/IES

\--service - name of IES-service. Default IES

\--url - url to download the update file. Default, url will be taken from <https://update.ipi.com/hes/build.json>

But you can override these parameters. For example, to update IES offline, from the file "linux\_x64\_latest.tar.gz", located in the user's home directory, you can run the script as follows:

`/opt/IES/update.sh --url file://~/linux_x64_latest.tar.gz`

or, if the update is on another of your resources:\
`update.ps1 --url https://<your_resource/linux_x64_latest.tar.gz`

## Option 2 (without using a script)

### 2.1. Stopping IES Service

```
  $ sudo systemctl stop IES
```

### 2.2. Backup the IES binaries and the configuration file

```
  $ sudo mv /opt/IES /opt/IES.old
```

### 2.3. Backup the Database

* For MySQL database:

The following command will create a copy (dump) of the database `hesdb` in file `hesdb.sql` in `/opt/IES.old` directory:

```
  $ sudo mysqldump -uroot -p<MySQL_root_password>  hesdb > /opt/IES.old/hesdb.sql
```

change `<MySQL_root_password>` with your real password.

* For Microsoft SQL Server database:

The following command will create a backup of the database `hesdb` in file `hesdb.bak` in `/var/opt/mssql/data` directory:

```
sqlcmd -S localhost -U SA -Q "BACKUP DATABASE [hesdb] TO DISK = N'/var/opt/mssql/data/hesdb.bak' WITH NOFORMAT, NOINIT, NAME = 'db-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
```

### 2.4. Download a new version of the IES

```
$ cd ~
$ curl -O https://update.ipi.com/hes/linux_x64_latest.tar.gz
$ tar -xvf linux_x64_latest.tar.gz
$ sudo mv IES /opt/
```

### 2.5. Restore the configuration file

```
  $ sudo cp /opt/IES.old/appsettings.Production.json /opt/IES/appsettings.Production.json
```

### 2.6. Restart the IES and check its status

```
  $ sudo systemctl restart IES
  $ sudo systemctl status IES

  
  ● IES-ipi.example.com.service - IPI Enterprise Service
   Loaded: loaded (/usr/lib/systemd/system/IES-ipi.example.com.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-03-25 10:48:12 UTC; 16s ago
 Main PID: 4657 (IES.Web)
   CGroup: /system.slice/IES.service
           └─4657 /opt/IES/IES.Web

Mar 25 10:48:12 hesservertest systemd[1]: Started IPI Enterprise Service.
```

**After checking that the update was successful and everything works fine, you can delete copies of the database and server:**

```
$ sudo rm -rf /opt/IES.old
```

## If something goes wrong, you can restore the IES server using the following commands

Restore the folder with previous IES version:

```
$ sudo systemctl stop IES
$ sudo mv /opt/IES.old /opt/IES
```

Restore the Database:

* For MySQL database:

```
$ sudo mysql -uroot -p<MySQL_root_password> hesdb < /opt/IES.old/hesdb.sql
```

change `<MySQL_root_password>` with your real password.

* For Microsoft SQL Server database:

```
$ sqlcmd -S localhost -U  SA -Q "RESTORE DATABASE [hesdb] FROM DISK = N'/var/opt/mssql/data/hesdb.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5"
```

then restart IES:

```
$ sudo systemctl  start IES
```

### As an alternative, you can make updates via a web interface on your IES server

1. Open the IES server.
2. Open section **Settings** → **Parameters** on the sidebar → **Server Update**
3. Type address in the field **Service Name** (by default “IES.service”)
4. In the section with available updates, Click **Update**

{% hint style="info" %}
Note: that way of updating IES available **only** for servers deployed on Linux
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://enterprise-ipi-en.hideez.com/ipi-enterprise-server/deployment/hes-update/linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
