﻿# Update BRIX AI in an air-gapped environment

> [HTML Version](update-cortex-air-gapped.html)

When a new version of **BRIX AI** is released, download the archive with updated installation files and transfer your configuration settings from the environment variables file. Below are the steps to update an offline installation using Docker Swarm.

## Step 1. Prepare update files

1. Before updating, create a backup copy of your current `.env` environment variables file:

````
cp ~/elma-cortex/docker-swarm/.env ~/elma-cortex-env-backup.env

2. ````
On a machine with internet access, download the new version of the archive. To do this, download and run the script that prepares files for offline installation by executing the following commands:

````
cd ~  
curl -fsSL -o cortex-offline-swarm.sh \\  
 https://dl.elma365.com/extensions/elma-cortex/latest/cortex-offline-swarm.sh  
chmod +x cortex-offline-swarm.sh  
./cortex-offline-swarm.sh --pull

````
If you have already downloaded and extracted the archive, run the following commands, specifying the path to the `offline` folder:

````
cd ~/elma-cortex/docker-swarm/offline  
chmod +x cortex-offline-swarm.sh  
./cortex-offline-swarm.sh –pull

3. ````
Transfer the new files to the isolated environment using any file transfer method, such as a USB drive or SCP protocol if a secure connection is available. Example using SCP:

````
scp -r elma-cortex-X.Y.Z user@air-gapped-server:~/

4. ````
Push images to your private registry using one of the methods described in [Install BRIX AI in an air-gapped environment](cortex-air-gapped.md#push-images-to-registry).

## Step 2. Update installation configuration

1. Compare the saved backup copy with the new `.env` file to identify settings added in the latest version. Run the following command:

````
diff ~/elma-cortex-env-backup.env ~/elma-cortex/docker-swarm/.env

2. ````
Transfer setting values from your custom configuration by running one of the following commands:

- To replace the new `.env` file with your backup copy and manually add new parameters from the latest version:

````
cp ~/elma-cortex-env-backup.env ~/elma-cortex/docker-swarm/.env

- ````
To edit the new `.env` file directly and transfer modified values from your backup copy:

````
nano ~/elma-cortex/docker-swarm/.env

## ````
Step 3. Apply update

1. If you use a private registry that requires authentication, log in to Docker:

````
docker login your-registry.example.com

2. ````
To apply the update, run the installation script:

````
chmod +x install.sh  
./install.sh
````