Docker

HES update - Docker

To update the HES server for Docker, you have to:

  1. Disable the Data Protection on the HES.

  2. Update the server using the following instruction.

  3. Enable Data Protection again.

Create a folder for backup

$ sudo mkdir /opt/HES.old

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

  • MySQL Database:

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

$ cd /opt/HES/
$ sudo sh -c "docker exec hes-mysql /usr/bin/mysqldump -u root --password=password db > /opt/HES.old/db.sql"
  • MS SQL Database:

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

 $ cd /opt/HES/
 $ sudo docker exec -it hes-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "C00ll_Passwrd_here"  -Q "BACKUP DATABASE [db] TO DISK = N'/var/opt/mssql/data/db.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/HES/docker-compose.yml file

Stop containers:

$ cd /opt/HES/
$ sudo docker compose down

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

$ sudo docker save -o /opt/HES.old/hes.tar hes

Remove image of HES:

$ 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 HES server using the following commands:

Stop containers:

$ cd /opt/HES/
$ sudo docker compose down

Remove image of HES:

$ 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/HES.old/db.sql | sudo docker exec -i hes-mysql /usr/bin/mysql -u root --password=password db
$ 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/HES/
 $ sudo docker exec -it hes-mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "C00ll_Passwrd_here"  -Q "RESTORE DATABASE [db] FROM DISK = N'/var/opt/mssql/data/db.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5"

instead of "C00ll_Passwrd_here", enter your password here, which you specified in the /opt/HES/docker-compose.yml file

Restore old image of HES from tar file:

$ sudo docker load -i /opt/HES.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/HES.old

Last updated