# Creating/Restoring snapshot from one cluster to another

**URL:** <https://discuss.elastic.co/t/creating-restoring-snapshot-from-one-cluster-to-another/108570>\
**Category:** Elasticsearch\
**Created:** [November 21, 2017, 2:24pm UTC](https://discuss.elastic.co/t/creating-restoring-snapshot-from-one-cluster-to-another/108570 "2017-11-21T14:24:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParitoshBh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paritoshbh/32/22487_2.png) [@ParitoshBh](https://discuss.elastic.co/u/ParitoshBh)\
**Post date:** [November 21, 2017, 2:24pm UTC](https://discuss.elastic.co/t/creating-restoring-snapshot-from-one-cluster-to-another/108570/1 "2017-11-21T14:24:22Z")

</div>

I have 2 clusters,

- Cluster A with 2 nodes (Node A1 -\> Master+Data, Node A2 -\> Data) - Acts as development environment
- Cluster B with 1 node (Node B1 -\> Master+Data) - Acts as live environment

With this setup, I am trying to generate a snapshot with some indices (not all of them) in Cluster A and restore it in Cluster B. To do so,

- All the nodes in Cluster A and Cluster B have `path.repo` set to `/usr/local/elasticsearch/backups` (not a shared location but local to all nodes)
- I create snapshot on Cluster A using,

```auto
    $params = [
      'repository' => 'repo_name',
      'snapshot' => 'snap_test',
      'wait_for_completion' => true,
      'body' => [
        'indices' => 'indexA',
        'ignore_unavailable' => true,
        'include_global_state' => false
      ]
    ];

    $response = $client->snapshot()->create($params);

```

- Then the entire `/usr/local/elasticsearch/backups` is transferred to Cluster B wherein, snapshot is restored using,

```auto
    $params = [
      'wait_for_completion' => true,
      'repository' => 'repo_name',
      'snapshot' => 'snap_test'
    ];

    $response = $client->snapshot()->restore($params);

```

The problem I am facing is, on restoring the snapshot in Cluster B, the log starts showing error messages in log (following is an example),

`[2017-11-17T14:51:45,267][WARN][o.e.c.a.s.ShardStateAction] [node-XXX-data] [indexA][1] received shard failed for shard id [[indexA][1]], allocation id [S1Da2f4FTsOoHdCtuptyeQ], primary term [0], message [failed recovery], failure [RecoveryFailedException[[indexA][1]: Recovery failed on {node-XXX-data}{FJIxmnJOTyWrP2r2sij3pw}{SqS2ySz4SK66X14qDbXtsQ}{127.0.0.1}{127.0.0.1:9300}]; nested: IndexShardRecoveryException[failed recovery]; nested: IndexShardRestoreFailedException[restore failed]; nested: ElasticsearchException[failed to create blob container]; nested: AccessDeniedException[/usr/local/elasticsearch/backups/indices/cJjWvkWwSNqOP-2PQAavIQ/1]; ]`

Looking into the `/usr/local/elasticsearch/backups` directory created in Cluster A, the `/usr/local/elasticsearch/backups/indices/cJjWvkWwSNqOP-2PQAavIQ/1` doesn't exist at all! This makes me think if I know the snapshot creation process at all.

I was under the impression that creating snapshot on Node A1 will pull all the distributed data across different nodes (in this case Node A2) and dump the snapshot at `/usr/local/elasticsearch/backups` which is essentially what I am looking for since the option to store data in cloud and/or shared location isn't available.

It would be great if someone could better explain the working of Snapshots (or point me to a blog/KB article) and help out with this situation 🙂

---

<div class="post-metadata">

**Author:** ![mujtabahussain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mujtabahussain/32/17514_2.png) [@mujtabahussain](https://discuss.elastic.co/u/mujtabahussain)\
**Post date:** [November 22, 2017, 12:45am UTC](https://discuss.elastic.co/t/creating-restoring-snapshot-from-one-cluster-to-another/108570/2 "2017-11-22T00:45:23Z")

</div>

Quick question.

When you are creating a snapshot from cluster A, you are saving the snapshot to location X. And cluster B will restore from location X as well.

Am I correct in reading that X is the same as `path.repo` ?

And if not, do both clusters have necessary permissions to read/write from/to X?

---

<div class="post-metadata">

**Author:** ![ParitoshBh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paritoshbh/32/22487_2.png) [@ParitoshBh](https://discuss.elastic.co/u/ParitoshBh)\
**Post date:** [November 22, 2017, 1:43pm UTC](https://discuss.elastic.co/t/creating-restoring-snapshot-from-one-cluster-to-another/108570/3 "2017-11-22T13:43:21Z")

</div>

> When you are creating a snapshot from cluster A, you are saving the snapshot to location X. And cluster B will restore from location X as well.  
> Am I correct in reading that X is the same as path.repo ?

Correct, location X is the same as `path.repo` however it isn't a shared location and instead local to the node.

> And if not, do both clusters have necessary permissions to read/write from/to X?

They do!

One point I missed out in initial post was that the index gets restored partially (with red status) and then fails subsequently. Eg. When I tried it out recently, out of 714000 documents, only 351000 were restored.

---

<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 20, 2017, 1:43pm UTC](https://discuss.elastic.co/t/creating-restoring-snapshot-from-one-cluster-to-another/108570/4 "2017-12-20T13:43:22Z")

</div>

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