# Will the snapshot repository able to capture the changes in mappings?

**URL:** <https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244>\
**Category:** Elasticsearch\
**Tags:** slm-snapshot-lifecycle-management, snapshot-and-restore\
**Created:** [July 26, 2023, 3:43am UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244 "2023-07-26T03:43:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian.chan](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@ian.chan](https://discuss.elastic.co/u/ian.chan)\
**Post date:** [July 26, 2023, 3:43am UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/1 "2023-07-26T03:43:03Z")

</div>

Hi.

Let's say I have registered a snapshot repository for an index A, with slm policy taking snapshot every hour.  
Then I add a new field in the mapping of the index A, and add some new documents with values in this new field.  
My questions are:

1. Will the snapshot repository able to capture the changes?
2. If I have another index named B, that have the same mapping as index A before the above changes, and also restored data using the snapshots in the snapshot repository before the above changes. Now after the above changes, can I restore the data into index B using the snapshot repository, given that index B is still using the old mapping?
3. Continue on the discussion of point 2, if I first manually update the mapping of Index B, can I now restore the data of the latest snapshot into index B?
4. If I create a new index C, using the latest mapping of index A, can I restore the data into this index C using the snapshot repository?

Many Thanks!

---

<div class="post-metadata">

**Author:** ![Opster\_support](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/opster_support/32/56687_2.png) [@Opster\_support](https://discuss.elastic.co/u/Opster_support)\
**Post date:** [July 26, 2023, 6:14pm UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/2 "2023-07-26T18:14:47Z")

</div>

1. Yes, the snapshot repository will capture the changes. Snapshots in Elasticsearch and OpenSearch are incremental. This means that each new snapshot only stores data that has changed since the last successful snapshot. When you add a new field to the mapping of an index and add new documents, these changes will be included in the next snapshot.

2. No, you cannot restore the data into index B using the snapshot repository if index B is still using the old mapping. The reason is that the snapshot restore process does not allow for the mapping of the index to be changed. The mapping of the index at the time of the snapshot is what will be restored. If the mapping of the index has changed since the snapshot was taken, the restore process will fail.

3. Yes, if you first manually update the mapping of Index B to match the mapping of the snapshot you want to restore, you can now restore the data of the latest snapshot into index B. The mapping of the index at the time of the restore needs to match the mapping of the index at the time of the snapshot.

4. Yes, if you create a new index C, using the latest mapping of index A, you can restore the data into this index C using the snapshot repository. The mapping of the new index C needs to match the mapping of the index at the time of the snapshot. The restore process will then restore the data into the new index C.

Remember, before performing any operations, it's always a good idea to test them in a non-production environment to ensure they work as expected.

---

<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 26, 2023, 6:14pm UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/3 "2023-07-26T18:14:47Z")

</div>

OpenSearch/OpenDistro are AWS run products and differ from the original Elasticsearch and Kibana products that Elastic builds and maintains. You may need to contact them directly for further assistance.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 26, 2023, 7:58pm UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/4 "2023-07-26T19:58:54Z")

</div>

> [@ian.chan](#):
>
> - If I have another index named B, that have the same mapping as index A before the above changes, and also restored data using the snapshots in the snapshot repository before the above changes. Now after the above changes, can I restore the data into index B using the snapshot repository, given that index B is still using the old mapping?
> - Continue on the discussion of point 2, if I first manually update the mapping of Index B, can I now restore the data of the latest snapshot into index B?
> - If I create a new index C, using the latest mapping of index A, can I restore the data into this index C using the snapshot repository?

The restore API allows you to restore an index from a snaphot. This will be restored with the mappings that existed when the snapshot was taken. The index can be restored into its original name or be restored using a different name. The restore process does however NOT allow you to merge data from a snapshotted index into another index, so the answer to questions 2, 3 and 4 is **No**.

> [@Opster\_support](#):
>
> Snapshots in Elasticsearch and OpenSearch are incremental. This means that each new snapshot only stores data that has changed since the last successful snapshot.

Notev that this is not strictly true. Snapshots work at the segment level and not at the data level. If a segment within a shard has not changed between snapshots, it will be reused and not copied multiple times. If segments have merged it is however possible that the snapshot repository will contain multiple segments holding the same data.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [July 26, 2023, 9:37pm UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/5 "2023-07-26T21:37:24Z")

</div>

> [@Opster\_support](#):
>
> Snapshots in Elasticsearch and OpenSearch are incremental. This means that each new snapshot only stores data that has changed since the last successful snapshot.

This is not correct. Snapshots in Elasticsearch are _deduplicated_, but logically independent, quite unlike incremental backups which depend on earlier backups.

> [@Opster\_support](#):
>
> No, you cannot restore the data into index B using the snapshot repository if index B is still using the old mapping. The reason is that the snapshot restore process does not allow for the mapping of the index to be changed.

This is not correct. When you restore an index, you restore its mapping too.

> [@Opster\_support](#):
>
> Yes, if you first manually update the mapping of Index B to match the mapping of the snapshot you want to restore, you can now restore the data of the latest snapshot into index B.

This is also not correct, for the same reason. No need to manually update any mappings.

> [@Opster\_support](#):
>
> The mapping of the new index C needs to match the mapping of the index at the time of the snapshot. The restore process will then restore the data into the new index C.

This is also not correct, for the same reason. The restore process restores both data and mappings.

Was this answer partially written by OpsGPT like [some of your earlier answers](https://discuss.elastic.co/t/how-to-secure-the-elasticsearch-api/339092/2)? It's very nicely written, but fundamentally incorrect.

---

<div class="post-metadata">

**Author:** ![ian.chan](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@ian.chan](https://discuss.elastic.co/u/ian.chan)\
**Post date:** [July 27, 2023, 1:28am UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/6 "2023-07-27T01:28:41Z")

</div>

Hi.

Thank you for the explanation.

Sound like the restore api will , if necessary, replace all the existing data and mapping of the index I am restoring to using the snapshot, did I get you right?

Also, if the mapping of the snapshot or the mapping of the index I am restoring to had been set to {"dynamic":"strict"}, will it affect the restore?

Many Thanks!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 27, 2023, 5:19am UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/7 "2023-07-27T05:19:09Z")

</div>

If you want to restore an index that still exists in the cluster you will need to either first delete it and then restore it to the state of when the snapshot was taken or restore the index as a new index under a new name.

When you restore the mapping present at the time when the snapshot was taken is restored. Whether the mapping is strict or not has no impact on this.

---

<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 24, 2023, 5:19am UTC](https://discuss.elastic.co/t/will-the-snapshot-repository-able-to-capture-the-changes-in-mappings/339244/8 "2023-08-24T05:19:48Z")

</div>

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