Create snapshot API not working

We are new to the snapshot-and-restore 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.

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:

{
  "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.

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.

1 Like

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

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.

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