1

I have indices i need to restore from snapshot, by using rename_pattern and rename_replacement. Can someone help me with the pattern and replacement?

Let's say my input index name is: "abc_def_r22_0" and I want it restored as "abc_def_r44_0"

NUM="44"
 POST /_snapshot/my_backup/snapshot_1/_restore
{
 "indices": "abc_def_r22_0",
 "ignore_unavailable": "true",
 "include_global_state": false,
 "rename_pattern": "\\d\\d",
 "rename_replacement": "$1'$NUM'_0"
 }
Subhrajyoti Das
  • 2,685
  • 3
  • 21
  • 36
StoneAgeRebel
  • 33
  • 1
  • 8

1 Answers1

3

You may use

_r[0-9]+_

and replace with _r$NUM_.

The _r[0-9]+_ will match _r, 1 or more digits, and a _, so you need to replace it with _r, then a new number and a _.

See the regex demo.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563