# Snapshot selected indices doesn't work

**URL:** <https://discuss.elastic.co/t/snapshot-selected-indices-doesnt-work/364010>\
**Category:** Elasticsearch\
**Tags:** snapshot-and-restore\
**Created:** [July 29, 2024, 8:50pm UTC](https://discuss.elastic.co/t/snapshot-selected-indices-doesnt-work/364010 "2024-07-29T20:50:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sliu](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sliu](https://discuss.elastic.co/u/sliu)\
**Post date:** [July 29, 2024, 8:50pm UTC](https://discuss.elastic.co/t/snapshot-selected-indices-doesnt-work/364010/1 "2024-07-29T20:50:37Z")

</div>

I'm running Elasticsearch on aws ec2, self-hosting, and snapshot to s3. Snapshot works fine except that it always copy ALL indices. Here're commands I used:  
(1) curl -XPUT localhost:9200/\_snapshot/mybackup -H 'Content-Type: application/json' -d   
'{"indices":"index1,index2","type":"s3","settings":{"bucket":"mybucket","base\_path":"path1/mysnapshot","region":"us-east-1"}}'  
(2) curl -XPUT localhost:9200/\_snapshot/mybackup/mysnapshot

I also tried {"indices":["index1","index2"], ...}, that didn't help -- still ALL indices get copied to s3.

Thanks for any help.

---

<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 29, 2024, 9:19pm UTC](https://discuss.elastic.co/t/snapshot-selected-indices-doesnt-work/364010/2 "2024-07-29T21:19:40Z")

</div>

You need to specify the indices you want to snapshot in the create-snapshot request. See [these docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/create-snapshot-api.html) for more information.

---

<div class="post-metadata">

**Author:** ![sliu](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sliu](https://discuss.elastic.co/u/sliu)\
**Post date:** [July 30, 2024, 1:00pm UTC](https://discuss.elastic.co/t/snapshot-selected-indices-doesnt-work/364010/3 "2024-07-30T13:00:36Z")

</div>

Thanks for the response. Finally got it to work with this sequence:  
(1) curl -XPUT localhost:9200/\_snapshot/mybackup -H 'Content-Type: application/json' -d  
'{"indices":"index1,index2","type":"s3","settings":{"bucket":"mybucket","base\_path":"path1/mysnapshot","region":"us-east-1"}}'  
(2) curl -XPUT localhost:9200/\_snapshot/mybackup/snapshot1 -H 'Content-Type: application/json' -d  
'{"indices":"index1,index2","type":"s3","settings":{"bucket":"mybucket","base\_path":"path1/mysnapshot","region":"us-east-1"}}'

Hope it'd be simplified in future.  
Thanks.

---

<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 30, 2024, 1:18pm UTC](https://discuss.elastic.co/t/snapshot-selected-indices-doesnt-work/364010/4 "2024-07-30T13:18:18Z")

</div>

> [@sliu](#):
>
> Hope it'd be simplified in future.

It's simpler than that already today. The first API call doesn't need `indices` and the second doesn't need `settings` or `type`.
