# Docker

**Migration from 3.10 (or less) to 3.11 (or up) requires additional steps because we have significantly improved the data protection mechanism - now it is built on certificates and doesn't require entering the password manually on server start. Please follow these steps to update your IES:**

1. Update all IPI Clients to 3.16.X, the new version can work with both old and new versions of the IES.
2. Disable the Data Protection on the IES.
3. Update the server using the following instruction.
4. Enable Data Protection again.

#### Create folder for backup

```
sudo mkdir /opt/IES.old
```

Backup the Database (Optimal (for possible further recovery)):

* MySQL Database:

The following command will create a copy of the database (dump) in file hesdb.sql in `/opt/IES.old` directory (on host) from container with name `hes-mysql`:

```
cd /opt/IES/
sudo sh -c "docker exec hes-mysql /usr/bin/mysqldump -u root --password=password hesdb > /opt/IES.old/hesdb.sql"
```

* MS SQL Database:

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

```
cd /opt/IES/
sudo docker exec -it hes-mssql  /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P "C00ll_Passwrd_here"  -Q "BACKUP DATABASE [hesdb] TO DISK = N'/var/opt/mssql/data/hesdb.bak' WITH NOFORMAT, NOINIT, NAME = 'db-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
```

instead of "C00ll\_Passwrd\_here", enter your password here, which you specified in the `/opt/IES/docker-compose.yml` file

### Stop containers:

```
cd /opt/IES/
sudo docker compose down
```

(Optimal) Save the image of IES to a tar file (for possible further recovery):

```
sudo docker save -o /opt/IES.old/hes.tar hes
```

### Remove image of IES:

```
sudo docker rmi hes --force
```

To upgrade the server to the latest version, run commands:

```
sudo docker build . -t hes
```

and Restart containers:

```
sudo docker compose up -d
```

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

Stop containers:

```
cd /opt/IES/
sudo docker compose down
```

Remove image of IES:

```
sudo docker rmi hes --force
```

Restore the Database

* My SQL:

Start MySQL container only:

```
sudo docker compose up -d hes-mysql
```

Restore the MySQL Database from dump file:

```
sudo cat /opt/IES.old/hesdb.sql | sudo docker exec -i hes-mysql /usr/bin/mysql -u root --password=password hesdb
sudo docker compose down 
```

* MS SQL:

Start MS SQL container only:

```
sudo docker compose up -d hes-mssql
```

Restore the MS SQL Database from bak file:

```
cd /opt/IES/
sudo docker exec -it hes-mssql /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P "C00ll_Passwrd_here"  -Q "RESTORE DATABASE [db] FROM DISK = N'/var/opt/mssql/data/hesdb.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5"
```

instead of "C00ll\_Passwrd\_here", enter your password here, which you specified in the `/opt/IES/docker-compose.yml` file

Restore old image of IES from tar file:

```
sudo docker load -i /opt/IES.old/hes.tar
```

and start containers:

```
sudo docker compose up -d
```

### 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
```


---

# 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/docker.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.
