> For the complete documentation index, see [llms.txt](https://docs.datafy.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datafy.io/set-up-and-installation/uninstalling-datafy.md).

# Uninstalling Datafy

Uninstalling Datafy is just as simple as the initial installation. Except for the [preparation](#prepare-for-uninstall), the following steps are the same for uninstalling Sensor or AutoScaler.

## Prepare for Uninstall

If you have **AutoScaler** installed, before you can uninstall, you must turn off autoscaling for all volumes managed by Datafy. Turning off autoscaling returns your volumes to their original provisioned size and removes the virtualization layer managed by Datafy. This is critical for ensuring access to your data after Autoscaler is uninstalled.

{% hint style="info" %}
If you only have Sensor installed, you can skip this step
{% endhint %}

{% stepper %}
{% step %}
**Turn Off Autoscaling Rules**

If you have autoscaling rules active in your account, turn off any rules relevant to the instances you wish to uninstall from, in the [Autoscale Rules table](https://app.datafy.io/fleet-manager/autoscale-rules) in the Datafy app.

This ensures that autoscaling isn't activated for any new volumes while you are preparing for uninstalling.

<figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2FrI1LmAQROkkKuHedz7KW%2Fimage.png?alt=media&amp;token=1fb60be6-b5a5-46f7-a984-5e30ca40b858" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Identify Managed Volumes**

In the [All Volume table](https://app.datafy.io/fleet-manager/all-volumes) in the Datafy app, find all of the relevant volumes by filtering the status "Autoscaling active" in the dashboard

<div data-full-width="false"><figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2FiKgqWQl5Uh9DHufRklgK%2Fimage.png?alt=media&amp;token=4042e2e5-9ec7-42b7-acfa-38faac13a995" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Turn off Autoscaling**

Turn off the toggle in the "AutoScale" column for all of the relevant volumes.

<figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2FXw7g8uf4onsEXCIKWsQS%2Fimage.png?alt=media&amp;token=ac5104a4-5749-4bcb-b1e0-0a593f6176ea" alt=""><figcaption></figcaption></figure>

Similarly to the initial activation when autoscaling was turned on, this stage can take time, dependent on the size of the volume. You can track the progress in the All Volumes table, or in the Optimization Actions table in the [Reports](https://app.datafy.io/reports) tab.

<figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2FJXqwmpTCOES0XsFOO12W%2Fimage.png?alt=media&amp;token=37f3f24a-cf4d-47de-bfef-dc43a9a4d1eb" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="info" %}
On Kubernetes, each PersistentVolume keeps referencing its original volume ID until the workload that uses it next restarts. Restart those workloads, for example with `kubectl rollout restart`, to trigger the ID swap before you uninstall. For details, see [AutoScaler on Kubernetes — Preparing to Uninstall](https://docs.datafy.io/how-it-works/autoscaler-on-kubernetes.md#preparing-to-uninstall).
{% endhint %}

## Uninstall Datafy

{% hint style="warning" %}
Uninstalling AutoScaler when there are managed volumes can lead to loss of access to the data stored on those volumes. Always [turn off autoscaling](#prepare-for-uninstall) before uninstalling Autoscaler.
{% endhint %}

### EC2 Instance

Run the uninstall command with the version that's installed on the instance:

```sh
curl -sSfL https://agent.datafy.io/uninstall\?version=$VERSION | sh
```

{% hint style="info" %}
You can check which version is installed on your instance with the command:

```bash
sudo grep '^VERSION=' /etc/datafy/datafy.conf
```

{% endhint %}

### Kubernetes Cluster

Uninstall the Helm release:

```shellscript
helm uninstall datafy-agent --namespace datafy-agent
```

{% hint style="info" %}
Some Datafy components may remain in your cluster while volumes that were previously autoscaling are still in use. The components remove themselves once every one of those volumes has either had its ID swapped or been deleted. For details, see [AutoScaler on Kubernetes — Uninstalling](https://docs.datafy.io/how-it-works/autoscaler-on-kubernetes.md#uninstalling).
{% endhint %}

## Remove IAM Role

After uninstallation, remove the IAM role configured during the [initial setup](https://docs.datafy.io/set-up-and-installation/datafy-installation/permissions-configuration.md). You can do this in one of the following ways:

1. Remove the ARN from the Permission section of the [account settings](https://app.datafy.io/settings).
2. Delete the role from your AWS account, by deleting the CloudFormation stack or Terraform module.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.datafy.io/set-up-and-installation/uninstalling-datafy.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
