> 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/virtual-private-cloud/azure/hivel-on-premises-deployment-guide-azure/uninstall-and-cleanup.md).

# Uninstall and Cleanup

Uninstalling this deployment touches more than the VM - work through the steps below in order so nothing is left running or billable, and no credential is left valid, after you're done.

### Step 1 - Back Up Anything You Need Before Deleting

* Take a final pg\_dump export of the insightly database, and/or a final manual Azure Database for PostgreSQL backup, if there's any chance you'll need this data again.
* Export any logs you need to retain from /var/log/hivel/ on the VM.

### Step 2 - Decide on Database Retention

The Azure Database for PostgreSQL server is not removed by stopping service. Decide whether to:

* **Keep it** - useful if you plan to reinstall or need the data retained for compliance.
* **Delete it** - in the Azure Portal, delete the PostgreSQL Flexible Server resource once you've confirmed you no longer need the data (and have taken the backup from Step 1). Also check for and delete any leftover manual snapshots or extended-retention backups taken during setup or testing, if applicable.

### Step 3 - Stop and Remove Services, Then Terminate the VM

{% code expandable="true" %}

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

{% endcode %}

**Remove the Docker network:** (run on the VM, if created).

{% code expandable="true" %}

```
docker network rm microservices_network 
```

{% endcode %}

Then terminate VM at the Azure Portal (or via az vm delete). Terminating the VM removes, automatically and without further action on the machine: all containers, the Docker network and volumes, pulled Docker images, the config/.env file, license file copies, the log-rotation cron job, and /var/log/hivel/.

### Step 4 - Clean Up Azure Resources That Don't Die With the VM

Terminating VM does not remove resources that sit alongside them. Delete or clean up, as applicable to your setup:

* Any Azure Load Balancer created to front the VM.
* DNS records pointing at the deployment (e.g. hivel.yourcompany.com), if you configured DNS/Caddy HTTPS in DNS Setup.
* Key Vault access policies, role assignments, and secrets created to store or retrieve database admin credentials.
* Attached managed disks, if not set to auto-delete with the VM.
* Any public IPs and Network Security Groups created specifically for VM, if not shared with other resources.

### Step 5 - Revoke Credentials That Live Outside the VM

* `docker logout 730335373269.dkr.ecr.ap-south-1.amazonaws.com` on any machine other than the terminated VM (e.g. a laptop or jump host used for setup).
* Deactivate or rotate the AWS IAM key used for aws configure, if it was ever configured outside the VM.
* Delete any backed-up copies of license\_signed.json / hivel\_onprem\_public.pem kept in a secrets manager, config repo, or elsewhere.

### Step 6 - Revoke Third-Party Integration Credentials

If you connected any of the following during setup, revoke them now:

* GitLab Personal Access Token
* Jira API token
* SonarQube token
* Bitbucket App Password
* Azure AD App Registration for Outlook - delete the registration, or at minimum expire the client secret (this lives in the Azure Portal, not on your hosts, so it's easy to forget)

### Step 7 - Close Out on Hivel's Side

Email <support@hivel.ai> and request:

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

**Next step:** Security and Secrets.

<br>

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

{% column %}

{% endcolumn %}

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