# AccessDeniedException when taking a snapshot of ES index in local machine

**URL:** <https://discuss.elastic.co/t/accessdeniedexception-when-taking-a-snapshot-of-es-index-in-local-machine/289848>\
**Category:** Elasticsearch\
**Tags:** docker, snapshot-and-restore\
**Created:** [November 22, 2021, 4:38pm UTC](https://discuss.elastic.co/t/accessdeniedexception-when-taking-a-snapshot-of-es-index-in-local-machine/289848 "2021-11-22T16:38:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milindyedge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/milindyedge/32/77188_2.png) [@milindyedge](https://discuss.elastic.co/u/milindyedge)\
**Post date:** [November 22, 2021, 4:38pm UTC](https://discuss.elastic.co/t/accessdeniedexception-when-taking-a-snapshot-of-es-index-in-local-machine/289848/1 "2021-11-22T16:38:32Z")

</div>

Getting below error when taking snapshot of the index.

----------------------- Error -----------------------

```auto
java.lang.IllegalStateException: Unable to access 'path.repo' (/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot)
es02 | Likely root cause: java.nio.file.AccessDeniedException: /Users

```

```auto
version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
    container_name: es01
    environment:
      - node.name=es01
      - node.roles=master,data
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - path.repo=/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./volumes/elasticsearch/data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
    container_name: es02
    environment:
      - node.name=es02
      - node.roles=master,data
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - path.repo=/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9301:9200
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
    container_name: es03
    environment:
      - node.name=es03
      - node.roles=master,data
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - path.repo=/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9302:9200
    networks:
      - elastic

volumes:
  data01:
    driver: local

networks:
  elastic:
    driver: bridge

```

----------------docker-compose.yml-------------------  
I have tried giving permission to the snapshot directory with this command for 'mlyedge', 'root', '1000' users but none of this seem to be resolving the issue.

```auto
sudo chown -R mlyedge:mlyedge /Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot

```

```auto
sudo chown -R root:root /Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot

```

```auto
sudo chown -R 1000:1000 /Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot

```

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [November 22, 2021, 5:45pm UTC](https://discuss.elastic.co/t/accessdeniedexception-when-taking-a-snapshot-of-es-index-in-local-machine/289848/2 "2021-11-22T17:45:25Z")

</div>

I think that perhaps the issue is that you set the `path.repo` to a filesystem / path that is on your host not inside the docker container so docker knows nothing about it... I think you are going to need to mount or bind that for the docker container as well I believe.

I am not the docker expert on mounting storage but perhaps look here

> **[Manage data in Docker](https://docs.docker.com/storage/)**
>
> Overview of persisting data in containers

---

<div class="post-metadata">

**Author:** ![milindyedge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/milindyedge/32/77188_2.png) [@milindyedge](https://discuss.elastic.co/u/milindyedge)\
**Post date:** [November 30, 2021, 11:15pm UTC](https://discuss.elastic.co/t/accessdeniedexception-when-taking-a-snapshot-of-es-index-in-local-machine/289848/3 "2021-11-30T23:15:00Z")

</div>

Hi Thank you. This was helpful.

---

<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 28, 2021, 11:15pm UTC](https://discuss.elastic.co/t/accessdeniedexception-when-taking-a-snapshot-of-es-index-in-local-machine/289848/4 "2021-12-28T23:15:27Z")

</div>

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