> For the complete documentation index, see [llms.txt](https://docs.hivel.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hivel.ai/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/uninstall-and-cleanup.md).

# Uninstall and Cleanup

**Objective:** Cleanly uninstall Hivel and revoke all credentials

Uninstalling requires more than stopping containers. Complete these steps in order.

### Step 1: Back Up Before Deleting

**Application/Location:** Host (via SSH)

Take a final backup of any data you need to retain:

```bash
pg_dump -h $DB_HOST -U postgres -d insightly -F c -f /backups/insightly_final.dump
```

Export any logs from `/var/log/hivel/` on the host that you need to retain.

### Step 2: Stop and Remove Services

**Application/Location:** Host (via SSH)

Run:

```bash
./deploy.sh --stop
docker-compose -f services/vm/docker-compose.yml down
```

Remove the Docker network:

```bash
docker network rm microservices_network
```

### Step 3: Decide on Database Retention

**Application/Location:** Host (via SSH)

The `insightly` PostgreSQL database is not removed by the commands above. Decide:

**Option A: Keep the database (for future reinstall)**

Leave it intact. No action needed.

**Option B: Delete the database**

Run:

```bash
sudo -u postgres psql -c "DROP DATABASE insightly;"
```

### Step 4: Decommission the Host

**Application/Location:** Your hypervisor/cloud console

Terminate the host VM. Terminating it removes everything in one action:

* All containers
* The `microservices_network` Docker network
* All Docker volumes and pulled images
* The `.env` file
* License file copies
* Log-rotation cron job
* `/var/log/hivel/` directory
* Host-level firewall rules

No further steps are needed on the host machine once it is terminated.

### Step 5: Clean Up Cloud Infrastructure (if applicable)

**Application/Location:** Your cloud provider console

If your infrastructure requires manual cleanup:

* Confirm attached storage/EBS volumes have "delete on termination" enabled, or delete them manually
* Release any Elastic/static IP addresses assigned to the host
* Delete security groups created specifically for this host (if not auto-removed)
* Remove or update any DNS records (e.g., `hivel.yourcompany.com` if Caddy/HTTPS was set up)

### Step 6: Revoke ECR and AWS Credentials

**Application/Location:** Any machine where AWS CLI was configured (laptop, jump host, etc.)

Run:

```bash
docker logout 730335373269.dkr.ecr.ap-south-1.amazonaws.com
```

Deactivate or rotate the AWS IAM key used for `aws configure` if it was configured anywhere outside the terminated hosts.

Delete any backed-up copies of:

* `license_signed.json`
* `hivel_onprem_public.pem`

(Search in secrets managers, config repositories, or other secure storage locations)

### Step 7: Revoke Third-Party Integration Credentials

**Application/Location:** The respective application/console for each integration

Revoke or delete credentials for any tools you connected:

* **GitLab:** Deactivate/delete the Personal Access Token
* **Jira:** Deactivate/delete the API token
* **SonarQube:** Deactivate/delete the access token
* **Bitbucket:** Deactivate/delete the App Password
* **Outlook integration (if used):** In the Azure Portal, delete the Azure AD App Registration or expire the client secret

### Step 8: Notify Hivel to Deactivate License

Send an email to <support@hivel.ai> requesting:

* Deactivation of the license grant tied to your `license_signed.json`
* Rotation/revocation of any ECR pull credentials issued specifically to you
* Confirmation that no customer record, webhook, or monitoring tied to the deployment remains active on Hivel's end

<br>

{% columns %}
{% column %} <a href="/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/upgrade-and-rollback.md" class="button primary" data-icon="backward">Back to Upgrade and Rollback</a>
{% endcolumn %}

{% column %}

{% endcolumn %}

{% column %} <a href="/self-managed-hivel-deployment/on-premises-generic/hivel-on-premises-deployment-guide-generic/security-and-secrets.md" class="button primary" data-icon="forward">Security and Secrets</a>
{% endcolumn %}
{% endcolumns %}
