> For the complete documentation index, see [llms.txt](https://platform9.com/kb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform9.com/kb/pmk/solutions/recover-persistent-volumes.md).

# Recover Persistent Volumes from "Terminating" State

## Problem

* Accidentally performed delete operation on PV instead of PVC.

{% tabs %}
{% tab title="Bash" %}

```bash
$ kubectl delete pv --all -n <Namespace>
```

{% endtab %}
{% endtabs %}

* All PV's across the Cluster are in **Terminating** state. Need to recover or set it back to "Bound" state.

## Environment

* Platform9 Managed Kubernetes - All versions

]Cause

* Default behaviour having the annotation **kubernetes.io/pv-protection,** it doesn't let controllers to delete PV till the time it is Bound with a PVC.

## Resolution

* As a workaround, the below operations can be carried out to try recover the PV back to bound state.
  * Take the backup of the existing PV

{% tabs %}
{% tab title="Bash" %}

```bash
kubectl get pv <pvname> -o yaml > pv.yaml
```

{% endtab %}
{% endtabs %}

```
- Edit the existing PV and delete the `spec.claimRef`  section. This will delete the PV completely. The PVC would be in lost status initially when the PV is deleted
```

{% tabs %}
{% tab title="Bash" %}

```bash
$ kubectl edit pv <pvname>
```

{% endtab %}
{% endtabs %}

```
- Edit the backed up PV YAML and delete the `metadata.deletionTimestamp` line.
```

{% tabs %}
{% tab title="Bash" %}

```bash
$ vi pv.yaml and delete the "metadata.deletionTimestamp" line
```

{% endtab %}
{% endtabs %}

```
- Create the PV and wait for the status to be updated. After recreating the PV, the PVC should be back in bound status.
```

{% tabs %}
{% tab title="Bash" %}

```bash
$ kubectl create -f pv.yaml
$ kubectl get pv
$ kubectl get pvc -n <namespace>
```

{% endtab %}
{% endtabs %}


---

# 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 dynamically by asking a question.

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

```
GET https://platform9.com/kb/pmk/solutions/recover-persistent-volumes.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 `build a script that syncs our docs to a CMS` 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.
