# Create snapshot API not working

**URL:** <https://discuss.elastic.co/t/create-snapshot-api-not-working/337244>\
**Category:** Elasticsearch\
**Tags:** docker, snapshot-and-restore\
**Created:** [June 29, 2023, 10:52pm UTC](https://discuss.elastic.co/t/create-snapshot-api-not-working/337244 "2023-06-29T22:52:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Z](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_z/32/122216_2.png) [@Mike\_Z](https://discuss.elastic.co/u/Mike_Z)\
**Post date:** [June 29, 2023, 10:52pm UTC](https://discuss.elastic.co/t/create-snapshot-api-not-working/337244/1 "2023-06-29T22:52:13Z")

</div>

We are new to the [snapshot-and-restore](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-snapshot-repo-api.html#put-snapshot-repo-api) function of Elasticsearch. Following the example below, we are trying to create a snapshot repository with the Console of Dev Tools.

The Elasticsearch server under test runs as a Docker container, and services runs with username `elasticsearch`. So, we created a folder in the user's home directory, `/usr/share/elasticsearch/my_backup_location` in the container.

```shell
PUT /_snapshot/my_backup
{
  "type": "fs",
  "settings": {
    "location": "/usr/share/elasticsearch/my_backup_location"
  }
}

```

However, the command did not work, and it got a "500-Internal Server Error" with the following error message:

```json
{
  "error": {
    "root_cause": [
      {
        "type": "repository_exception",
        "reason": "[my_backup] location [/usr/share/elasticsearch/my_backup_location] doesn't match any of the locations specified by path.repo because this setting is empty"
      }
    ],
    "type": "repository_exception",
    "reason": "[my_backup] failed to create repository",
    "caused_by": {
      "type": "repository_exception",
      "reason": "[my_backup] location [/usr/share/elasticsearch/my_backup_location] doesn't match any of the locations specified by path.repo because this setting is empty"
    }
  },
  "status": 500
}

```

We wonder if we are missing anything in the test above and will highly appreciate any hints and suggestions.

Please let us know if you need more information.

---

<div class="post-metadata">

**Author:** ![angelo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/angelo/32/61325_2.png) [@angelo](https://discuss.elastic.co/u/angelo)\
**Post date:** [June 30, 2023, 12:06am UTC](https://discuss.elastic.co/t/create-snapshot-api-not-working/337244/2 "2023-06-30T00:06:08Z")

</div>

Since you want to use what is considered a 'shared' filesystem, you first have to define (whitelist?) it in the elasticsearch.yml file as `path.repo: /usr/share/elasticsearch/my_backup_location`

With docker, you will have to pass it in with your `environment:` values or however you are specifying similar settings.

---

<div class="post-metadata">

**Author:** ![Mike\_Z](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_z/32/122216_2.png) [@Mike\_Z](https://discuss.elastic.co/u/Mike_Z)\
**Post date:** [June 30, 2023, 6:29pm UTC](https://discuss.elastic.co/t/create-snapshot-api-not-working/337244/3 "2023-06-30T18:29:42Z")

</div>

Thank you, @angelo. I have resolved the issue by editing the `elasticsearch.yml` file in the container.

> [@Angelo](#):
>
> in the elasticsearch.yml file as `path. Repo: /usr/share/elasticsearch/my_backup_location`

And, as you mentioned, the best practice is to pass in the configuration by the `environment` argument in `docker-compose.yml`. And, we will figure it out later on.

---

<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:** [July 28, 2023, 6:30pm UTC](https://discuss.elastic.co/t/create-snapshot-api-not-working/337244/4 "2023-07-28T18:30:39Z")

</div>

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