## Upgrading the Glasswall Halo OVA

Follow the steps below to upgrade your Glasswall Halo OVA while preserving MongoDB data.

---

### 1. Back up MongoDB data

First, create a MongoDB backup using `mongodump`.

```shell
kubectl port-forward svc/mongo-svc 27017
```

Open another terminal on the VM and run:

```shell
username=$(kubectl get secret mongodb-cdrplatform-cdrp-user -o json | jq -r '.data.username' | base64 -d)
password=$(kubectl get secret mongodb-cdrplatform-cdrp-user -o json | jq -r '.data.password' | base64 -d)

mongodump \
  --host localhost \
  --port 27017 \
  --db cdrplatform \
  --out halo_backup \
  -u "${username}" \
  -p "${password}"

zip -r halo_backup.zip halo_backup
```

---

### 2. Copy the backup to a local machine

```shell
scp glasswall@<ip-of-the-old-vm>:~/halo_backup.zip ./halo_backup.zip
```

---

### 3. Deploy a new VM

Create a new virtual machine using the latest OVA or VHD by following the VMware or Hyper-V deployment guide.

---

### 4. Copy the backup to the new VM

```shell
scp ./halo_backup.zip glasswall@<ip-of-the-new-vm>:~/
```

---

### 5. Restore MongoDB data on the new VM

```shell
kubectl port-forward svc/mongo-svc 27017
```

Open another terminal on the VM and run:

```shell
unzip halo_backup.zip

username=$(kubectl get secret mongodb-cdrplatform-cdrp-user -o json | jq -r '.data.username' | base64 -d)
password=$(kubectl get secret mongodb-cdrplatform-cdrp-user -o json | jq -r '.data.password' | base64 -d)

mongorestore \
  --host localhost \
  --port 27017 \
  --authenticationMechanism SCRAM-SHA-256 \
  --authenticationDatabase cdrplatform \
  -u "${username}" \
  -p "${password}" \
  halo_backup
```

---

### 6. Clean up backup files

```shell
rm -rf halo_backup halo_backup.zip
```

---