# Doubts and possible 'curl' problem to create and restore indices snapshot from pods CLI

**URL:** <https://discuss.elastic.co/t/doubts-and-possible-curl-problem-to-create-and-restore-indices-snapshot-from-pods-cli/318797>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Tags:** snapshot-and-restore\
**Created:** [November 13, 2022, 11:55am UTC](https://discuss.elastic.co/t/doubts-and-possible-curl-problem-to-create-and-restore-indices-snapshot-from-pods-cli/318797 "2022-11-13T11:55:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_T](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_t/32/97624_2.png) [@Carlos\_T](https://discuss.elastic.co/u/Carlos_T)\
**Post date:** [November 13, 2022, 11:55am UTC](https://discuss.elastic.co/t/doubts-and-possible-curl-problem-to-create-and-restore-indices-snapshot-from-pods-cli/318797/1 "2022-11-13T11:55:47Z")

</div>

Good morning.

Some colleagues in the office requested me to investigate how could they create a backup policy for their indices.

The first doubt I have is if using a NFS directory could work as an approach.  
The master nodes and data nodes would include the path.repo to that directory.

This is something I managed to do at home with VMs but I would like to apply that strategy also to K8s

If this is possible my colleagues dont want to use Kibana to manage the snapshot. So the option would be creating snapshot on daily basis and eventually running a restore from CLI too.

From the dev tool at home I managed to run succesfully the restore from the DevTools section in Kibana.  
I runned:

```auto
POST /_snapshot/my_fs_backup/my_snapshot_2022.11.12/_restore
{
  "indices": ".ds-filebeat-8.4.3-2022.11.04-000001,filebeat-8.4.3"
}

```

And it work perfectly

Now I tried to do it from the ubuntu's cli at home by using:

```auto
curl -XPUT --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:blablabla "https://localhost:9200/_snapshot/my_fs_backup/my_snapshot_2022.11.12/_restore" -d '{ "indices": ".dWs-filebeat-8.4.3-2022.11.04-000001,filebeat-8.4.3"}}'

```

Which returned:  
**{"error":"Incorrect HTTP method for uri [/\_snapshot/my\_fs\_backup/my\_snapshot\_2022.11.12/\_restore] and method [PUT], allowed: [POST]","status":405**}

I tried

```auto
curl -PUT --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:blablabla "https://localhost:9200/_snapshot/my_fs_backup/my_snapshot_2022.11.12/_restore" -d '{ "indices": ".dWs-filebeat-8.4.3-2022.11.04-000001,filebeat-8.4.3"}}'

```

which returned  
**{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}**

And well, this are basically my questions.  
A) Can I use this approach in our own self-manage K8s cluster to backup snapshot (NFS+CLI commands)?  
B) what is the right syntax I should use?

Thank you very much and best regards.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [November 13, 2022, 2:55pm UTC](https://discuss.elastic.co/t/doubts-and-possible-curl-problem-to-create-and-restore-indices-snapshot-from-pods-cli/318797/2 "2022-11-13T14:55:27Z")

</div>

> [@Carlos\_T](#):
>
> **{"error":"Incorrect HTTP method for uri [/\_snapshot/my\_fs\_backup/my\_snapshot\_2022.11.12/\_restore] and method [PUT], allowed: [POST]","status":405**}

Have you tried to use POST instead of PUT? The error message is saying that PUT is not allowed, you need to use POST.

---

<div class="post-metadata">

**Author:** ![Carlos\_T](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_t/32/97624_2.png) [@Carlos\_T](https://discuss.elastic.co/u/Carlos_T)\
**Post date:** [November 14, 2022, 3:20pm UTC](https://discuss.elastic.co/t/doubts-and-possible-curl-problem-to-create-and-restore-indices-snapshot-from-pods-cli/318797/3 "2022-11-14T15:20:47Z")

</div>

Good evening.

Thank you Leandro for you fast answer.  
Indeed, POST is what I had to use. And I did but I had an error related to the certificates and that's why I stop trying it.  
The issue dissapaired once I combined 'sudo' and 'POST'.

I tried more than restoring, so here you are some examples:

**Creating NFS repository:**

```auto
sudo curl -POST --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:blablaba -H'Content-Type: application/json' "https://localhost:9200/_snapshot/my_fs_backup?pretty" -d '{ "type": "fs", "settings": { "location": "/backups" }}'

```

**Creating NFS snapshot (It makes a backup of all indices)**

```auto
sudo curl -X PUT --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:blablabla "https://192.168.0.111:9200/_snapshot/my_fs_backup/%3Cmy_snapshot_%7Bnow%2Fd%7D%3E?pretty"

```

\*\*Restoring a couple of indices (filebeat and filebeat's datastream) from the snapshot I created yesterday with this name 'my\_snapshot\_2022.11.13' \*\*

```auto
sudo curl -POST --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:blablabla -H'Content-Type: application/json' "https://localhost:9200/_snapshot/my_fs_backup/my_snapshot_2022.11.13/_restore" -d '{ "indices": ".ds-filebeat-8.4.3-2022.11.13-000001,filebeat-8.4.3"}}'`

```

Everythink worked fine

I just hope I can use it in the K8s environment.

I have more doubts about how to deal with the already existing indices that force me to rename the restored ones, how to merge data so dashboard can show them,etc...

Thank you very much Leandro, and the rest of you who read it too.

Have a nice week 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 12, 2022, 3:21pm UTC](https://discuss.elastic.co/t/doubts-and-possible-curl-problem-to-create-and-restore-indices-snapshot-from-pods-cli/318797/4 "2022-12-12T15:21:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
