# Unable to take snapshot and restore using repository-hdfs

**URL:** <https://discuss.elastic.co/t/unable-to-take-snapshot-and-restore-using-repository-hdfs/17504>\
**Category:** Elasticsearch\
**Created:** [May 14, 2014, 6:09am UTC](https://discuss.elastic.co/t/unable-to-take-snapshot-and-restore-using-repository-hdfs/17504 "2014-05-14T06:09:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chetana](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@Chetana](https://discuss.elastic.co/u/Chetana)\
**Post date:** [May 14, 2014, 6:09am UTC](https://discuss.elastic.co/t/unable-to-take-snapshot-and-restore-using-repository-hdfs/17504/1 "2014-05-14T06:09:50Z")

</div>

I am using ES 1.1.1 and Hadoop hortonworks 2.2.2 and have installed the  
plugin '_repository-hdfs'  
([https://github.com/elasticsearch/elasticsearch-hadoop/tree/master/repository-hdfs](https://github.com/elasticsearch/elasticsearch-hadoop/tree/master/repository-hdfs)  
 [https://github.com/elasticsearch/elasticsearch-hadoop/tree/master/repository-hdfs](https://github.com/elasticsearch/elasticsearch-hadoop/tree/master/repository-hdfs))_ in  
ES. I have created one custom plugin action which invokes snapshot and  
restore and set hadoop related jars to ES\_CLASSPATH

The handleRequest(...) of the custom plugin action looks as below :  
public void handleRequest(final RestRequest request,  
final RestChannel channel) {  
LocalFileSystem fs = FileSystem.getLocal(new Configuration());  
Path path = new Path("backup");  
fs.delete(path, true);

```
PutRepositoryResponse putRepositoryResponse = 

```

client.admin().cluster().preparePutRepository("test-backup").setType("hdfs").  
.setSettings(ImmutableSettings.settingsBuilder().put("path", path)).get();

```
CreateSnapshotResponse createSnapshotResponse = 

```

client.admin().cluster().prepareCreateSnapshot("test-backup",  
"test-snap").setWaitForCompletion(true).setIndices("test").get();

client.admin().cluster().prepareGetSnapshots("test-backup").setSnapshots("test-snap").get().getSnapshots().get(0).state();

```
RestoreSnapshotResponse restoreSnapshotResponse = 
 client.admin().cluster().prepareRestoreSnapshot("test-backup", 

```

"test-snap").setIndices("test").setWaitForCompletion(true).execute().actionGet();

```
XContentBuilder builder = restContentBuilder(request);

```

builder.value("successfully done - " +  
putRepositoryResponse.isAcknowledged() +":"+  
createSnapshotResponse.getSnapshotInfo().status().getStatus()+  
":"+restoreSnapshotResponse.getRestoreInfo().status().getStatus());  
channel  
.sendResponse(new XContentRestResponse(request, OK, builder));  
}

After the first invocation, I get this error  
{"error":"UncategorizedExecutionException[Failed execution]; nested:  
IOException[Filesystem closed]; ","status":500}  
org.elasticsearch.snapshots.SnapshotCreationException:  
[test-backup:test-snap] failed to create snapshot  
at  
org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:251)  
at  
org.elasticsearch.snapshots.SnapshotsService.beginSnapshot(SnapshotsService.java:266)  
at  
org.elasticsearch.snapshots.SnapshotsService.access$600(SnapshotsService.java:82)  
at  
org.elasticsearch.snapshots.SnapshotsService$1$1.run(SnapshotsService.java:192)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)  
Caused by: java.io.IOException: Filesystem closed  
at org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:629)  
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1365)  
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:1307)  
at  
org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:384)  
at  
org.apache.hadoop.hdfs.DistributedFileSystem$6.doCall(DistributedFileSystem.java:380)  
at  
org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)  
at  
org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:380)  
at  
org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:324)  
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:905)  
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:886)  
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:783)  
at  
org.elasticsearch.hadoop.hdfs.blobstore.HdfsImmutableBlobContainer$1.run(HdfsImmutableBlobContainer.java:47)  
... 3 more

When the action is invoked second time, it throws  
{"error":"InvalidSnapshotNameException[[test-backup:test-snap] Invalid  
snapshot name [test-snap], snapshot with such name already  
exists]","status":400}  
org.elasticsearch.snapshots.InvalidSnapshotNameException:  
[test-backup:test-snap] Invalid snapshot name [test-snap], snapshot with  
such name already exists  
at  
org.elasticsearch.repositories.blobstore.BlobStoreRepository.initializeSnapshot(BlobStoreRepository.java:224)  
at  
org.elasticsearch.snapshots.SnapshotsService.beginSnapshot(SnapshotsService.java:266)  
at  
org.elasticsearch.snapshots.SnapshotsService.access$600(SnapshotsService.java:82)  
at  
org.elasticsearch.snapshots.SnapshotsService$1$1.run(SnapshotsService.java:192)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)

Someone pls help me to fix this exception

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f3777bf3-07f2-482b-a877-178f5ebf49d5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f3777bf3-07f2-482b-a877-178f5ebf49d5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:29am UTC](https://discuss.elastic.co/t/unable-to-take-snapshot-and-restore-using-repository-hdfs/17504/2 "2017-07-06T01:29:34Z")

</div>


