# Can't create snapshots after restoring data

**URL:** <https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328>\
**Category:** Elasticsearch\
**Created:** [July 31, 2018, 9:52am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328 "2018-07-31T09:52:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahrtr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahrtr/32/29551_2.png) [@ahrtr](https://discuss.elastic.co/u/ahrtr)\
**Post date:** [July 31, 2018, 9:52am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/1 "2018-07-31T09:52:40Z")

</div>

The elasticseach version is 6.2.2. Today I encountered an error when trying to create a snapshot after restoring data. Can anyone please provide any advices?

The test steps are as below,

1. Start an elasticsearch instance, and attach a volume to /usr/share/elasticsearch/data;
2. Generate some log data;
3. Create a repository using the following command successfully;

> curl -X PUT -H "Content-Type:application/json" -d '{"type":"fs", "settings":{"location": "/usr/share/elasticsearch/data/backup"}}' [http://10.97.116.168:9200/\_snapshot/ben\_backup](http://10.97.116.168:9200/_snapshot/ben_backup)

1. Create a snapshot using the following command successfully;

> curl -X PUT [http://10.97.116.168:9200/\_snapshot/ben\_backup/snap\_1](http://10.97.116.168:9200/_snapshot/ben_backup/snap_1)

1. Shutdown the elasticsearch instance;

2. Start a new elasticsearch instance on other node, and attached the same volume to /usr/share/elasticsearch/data;

3. Create a repository using the following command successfully;

> curl -X PUT -H "Content-Type:application/json" -d '{"type":"fs", "settings":{"location": "/usr/share/elasticsearch/data/backup"}}' [http://10.101.44.198:9200/\_snapshot/ben\_backup](http://10.101.44.198:9200/_snapshot/ben_backup)

1. Restore the snapshot using the following command successfully;

> curl -X POST [http://10.101.44.198:9200/\_snapshot/ben\_backup/snap\_1/\_restore](http://10.101.44.198:9200/_snapshot/ben_backup/snap_1/_restore)

1. Feed more log data into elasticsearch successfully;

2. Try to generate a new snapshot using the following command, but failed this time.  
curl -X PUT [http://10.101.44.198:9200/\_snapshot/ben\_backup/snap\_2](http://10.101.44.198:9200/_snapshot/ben_backup/snap_2)

The error response what I got was as below,

```
{
  "error": {
    "root_cause": [
      {
        "type": "snapshot_creation_exception",
        "reason": "[ben_backup:snap_2/eBS31A1mSFG1Ffu8FQmgRw] failed to create snapshot"
      }
    ],
    "type": "snapshot_creation_exception",
    "reason": "[ben_backup:snap_2/eBS31A1mSFG1Ffu8FQmgRw] failed to create snapshot",
    "caused_by": {
      "type": "access_denied_exception",
      "reason": "/usr/share/elasticsearch/data/backup/indices/Rd6MzRfdTiOOg6N0UIEdwg/meta-eBS31A1mSFG1Ffu8FQmgRw.dat"
    }
  },
  "status": 500
}

```

---

<div class="post-metadata">

**Author:** ![ahrtr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahrtr/32/29551_2.png) [@ahrtr](https://discuss.elastic.co/u/ahrtr)\
**Post date:** [July 31, 2018, 11:27am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/2 "2018-07-31T11:27:20Z")

</div>

Elasticsearch generated the following exceptions,

```
2018-07-31T09:39:25,272][WARN][o.e.s.SnapshotsService] [t-hprrzcjx5s27dyucxyux-es-b9f74b99f-h6xwp-default] failed to create snapshot [snap_2/eBS31A1mSFG1Ffu8FQmgRw]
org.elasticsearch.snapshots.SnapshotCreationException: [ben_backup:snap_2/eBS31A1mSFG1Ffu8FQmgRw] failed to create snapshot
	at org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:335) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.snapshots.SnapshotsService.beginSnapshot(SnapshotsService.java:364) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.snapshots.SnapshotsService.access$700(SnapshotsService.java:105) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.snapshots.SnapshotsService$1.lambda$clusterStateProcessed$1(SnapshotsService.java:282) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:573) [elasticsearch-6.2.2.jar:6.2.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_161]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/backup/indices/Rd6MzRfdTiOOg6N0UIEdwg/meta-eBS31A1mSFG1Ffu8FQmgRw.dat
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:?]
	at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434) ~[?:1.8.0_161]
	at java.nio.file.Files.newOutputStream(Files.java:216) ~[?:1.8.0_161]
	at org.elasticsearch.common.blobstore.fs.FsBlobContainer.writeBlob(FsBlobContainer.java:130) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat.writeBlob(ChecksumBlobStoreFormat.java:191) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat.write(ChecksumBlobStoreFormat.java:161) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:332) ~[elasticsearch-6.2.2.jar:6.2.2]
	... 7 more
[2018-07-31T09:39:25,280][WARN][r.suppressed] path: /_snapshot/ben_backup/snap_2, params: {repository=ben_backup, snapshot=snap_2}
org.elasticsearch.snapshots.SnapshotCreationException: [ben_backup:snap_2/eBS31A1mSFG1Ffu8FQmgRw] failed to create snapshot
	at org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:335) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.snapshots.SnapshotsService.beginSnapshot(SnapshotsService.java:364) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.snapshots.SnapshotsService.access$700(SnapshotsService.java:105) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.snapshots.SnapshotsService$1.lambda$clusterStateProcessed$1(SnapshotsService.java:282) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:573) ~[elasticsearch-6.2.2.jar:6.2.2]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_161]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/backup/indices/Rd6MzRfdTiOOg6N0UIEdwg/meta-eBS31A1mSFG1Ffu8FQmgRw.dat
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:?]
	at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434) ~[?:1.8.0_161]
	at java.nio.file.Files.newOutputStream(Files.java:216) ~[?:1.8.0_161]
	at org.elasticsearch.common.blobstore.fs.FsBlobContainer.writeBlob(FsBlobContainer.java:130) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat.writeBlob(ChecksumBlobStoreFormat.java:191) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.repositories.blobstore.ChecksumBlobStoreFormat.write(ChecksumBlobStoreFormat.java:161) ~[elasticsearch-6.2.2.jar:6.2.2]
	at org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:332) ~[elasticsearch-6.2.2.jar:6.2.2]
	... 7 more
```

---

<div class="post-metadata">

**Author:** ![ahrtr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahrtr/32/29551_2.png) [@ahrtr](https://discuss.elastic.co/u/ahrtr)\
**Post date:** [August 1, 2018, 12:40am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/3 "2018-08-01T00:40:10Z")

</div>

I changed the permission of the fs from 755 to 777, and it worked. I don't understand why I could create the snapshot successfully in the first time, but failed in the second elasticsearch instance.

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 1, 2018, 12:47am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/4 "2018-08-01T00:47:29Z")

</div>

`path.repo: [/data/sdd1/esbackup]`  
backup directory need share fs as nfs ,not local fs.

---

<div class="post-metadata">

**Author:** ![ahrtr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahrtr/32/29551_2.png) [@ahrtr](https://discuss.elastic.co/u/ahrtr)\
**Post date:** [August 1, 2018, 12:49am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/5 "2018-08-01T00:49:22Z")

</div>

What I used was a shared volume.

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 1, 2018, 12:54am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/6 "2018-08-01T00:54:24Z")

</div>

each node have access wirte and read data with elasticsearch user ?  
can write and read ?  
test by create file and write file change file or delete file.

---

<div class="post-metadata">

**Author:** ![ahrtr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahrtr/32/29551_2.png) [@ahrtr](https://discuss.elastic.co/u/ahrtr)\
**Post date:** [August 1, 2018, 12:59am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/7 "2018-08-01T00:59:15Z")

</div>

Previously the mod of the shared volume was 755, and it could be read/written by the first elasticsearch instance with elasticsearch user.

But it could only be ready by the second elasticsearch instance with user elasticsearch, and couldn't be written. After changing the mod to 777, then it worked. So it's a little confusing why it could be written by the first one, but couldn't by the second.

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [August 1, 2018, 1:03am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/8 "2018-08-01T01:03:05Z")

</div>

each node show the elasitcsearch user uid.  
maybe not same.

---

<div class="post-metadata">

**Author:** ![ahrtr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahrtr/32/29551_2.png) [@ahrtr](https://discuss.elastic.co/u/ahrtr)\
**Post date:** [August 1, 2018, 1:30am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/9 "2018-08-01T01:30:38Z")

</div>

@zqc0512 Thanks for the response.

---

<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:** [August 29, 2018, 1:38am UTC](https://discuss.elastic.co/t/cant-create-snapshots-after-restoring-data/142328/10 "2018-08-29T01:38:26Z")

</div>

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