Elasticsearch restore API to validate restore

Hi,

This is just a query about elasticsearch data restore.
I am trying to handle any kinds of failure while restoring elasticsearch data. Is there any API/curl command that can give me a response of a failed restore along with reason?

I am referring This link but could not find any such API here.

Best Regards,
Akshat Sharma

Hi @akshatsharma

the cat recoveries API will show you ongoing and past restores with type snapshot and can also display the failures if any for failed restores.

@Armin_Braun
Thank you for your response.
I tried the cat recovery APIs but it is not showing the failed restored(partially restored) index.

In my case, I want to handle a situation when elasticsearch data pvc does not have enough space left to restore an index.

For example:
I have 5gb of elasticsearch data pvc and let's say 3 gb of data stored in "journal-2020.01.27" index. So now there are only around 2 gb space left in elasticsearch data. Now I take a backup and then restore the index. Here the resrore API runs successfully but the response says "failed:1, sucessfull:2". That is, the index which contained 3 gb of data(journal-2020.01.27) was not restored successfully because there is no space left to restore it.

Now, even though it says "failed:1", the "journal-2020.01.27-restored_1580106173" index is created which does not contain any data.

Is there any way to handle this scenario?

Best Regards,
Akshat

@akshatsharma

sorry about the confusion there. You're right, you won't get enough details on the failures from the cat recoveries alone.

You could use cat shards though to get the reason for a shard being unassigned.

Is there any way to handle this scenario?

There is no automatic way of dealing with this. You'll have to make space on disk, remove the failed index from the cluster and rerun the restore for that failed index manually I'm afraid.

Thanks for your input.

I understand. but is there any API that could give me something like "State:Failed" or "Status:failed" or anything of that sort for such failed cases? I just want any kind of response which specifically gives the status and reason so I could use a flag and notify the users in post restore script.

Best regards,
Akshat

@akshatsharma

but is there any API that could give me something like "State:Failed" or "Status:failed"

The cat shards API (see cat shards API | Elasticsearch Guide [7.5] | Elastic) that I linked above gives you the failed shards that couldn't be allocated.
You could hit that API in case the restore response contains a number of failed shards larger than 0 and figure out the reason for the failures from it couldn't you?

Oh great!
Will try this. Thanks a lot @Armin_Braun!

Best Regards,
Akshat

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