Rename pattern of restoring snapshot API has an unexpected behavior

I'm using Elasticsearch 7.17.4, running with Docker.

I have a snapshot containing an index called metricbeat-7.12.0-2022.09.01, and I want it to be renamed with a prefix or a suffix.

However, like the image below, its name becomes prefix_metricbeat-7.12.0-2022.09.01_suffixprefix__suffix after restoring.

This is for testing, so there's only one index being restored. What I want is to add the prefix and suffix to any index being restored, so I use * for indices and (.*) for rename_pattern.

I don't know what's wrong with it, and I hope someone can tell me how to fix it.

Thanks.

You want (.+) rather than (.*). Elasticsearch uses Matcher#replaceAll to compute the renamed index, and this will behave in unexpected ways if your pattern matches an empty string.

I opened Rename-on-restore behaves weirdly if `rename_pattern` matches an unanchored empty string · Issue #89792 · elastic/elasticsearch · GitHub to report this bug.

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