# ETCD Backup Failing With Error Message "Error: could not rename /root/etcd\_backup0/.part"

## Problem

ETCD backup is failing with the error mentioned below.

{% tabs %}
{% tab title="ETCD Backup Error" %}

```javascript
# ETCDCTL_API=3 etcdctl snapshot save /root/etcd_backup0/
{"level":"info","ts":1666284121.098649,"caller":"snapshot/v3_snapshot.go:119","msg":"created temporary db file","path":"/root/etcd_backup0/.part"}
{"level":"info","ts":"2022-10-20T16:42:01.100Z","caller":"clientv3/maintenance.go:200","msg":"opened snapshot stream; downloading"}
{"level":"info","ts":1666284121.10057,"caller":"snapshot/v3_snapshot.go:127","msg":"fetching snapshot","endpoint":"127.0.0.1:2379"}
{"level":"info","ts":"2022-10-20T16:42:01.600Z","caller":"clientv3/maintenance.go:208","msg":"completed snapshot read; closing"}
{"level":"info","ts":1666284121.6521926,"caller":"snapshot/v3_snapshot.go:142","msg":"fetched snapshot","endpoint":"127.0.0.1:2379","size":"18 MB","took":0.553370829}
Error: could not rename /root/etcd_backup0/.part to /root/etcd_backup0/ (rename /root/etcd_backup0/.part /root/etcd_backup0/: file exists)
```

{% endtab %}
{% endtabs %}

## Environment

* Platform9 Managed Kubernetes – All Versions

## Cause

* The ETCD DB backup command mentioned below was intended to save the ETCD snapshot backup file under `/root/etcd_backup0/` directory.

{% tabs %}
{% tab title="Failed ETCD backup commad" %}

```javascript
# ETCDCTL_API=3 etcdctl snapshot save /root/etcd_backup0/
```

{% endtab %}
{% endtabs %}

* But Instead of that , the `/root/etcd_backup0/` is considered as the Database snapshot backup file name.
* Since a directory with that name is already present hence it is failing to take backup.

## Resolution

* ETCD backup command expects a file name as an argument which will be used to save the snapshot DB backup.
* Hence the ETCD backup command should always have the ETCD snapshot DB backup file name mention in it. For Example,

{% tabs %}
{% tab title="Working ETCD backup command" %}

```javascript
ETCDCTL_API=3 etcdctl snapshot save $HOME/etcd-backup-snapshot-$(date +%s).db
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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 current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmk/solutions/etcd-backup-failing-with-error-message-error-could-not-rename.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
