Skip to content

Commit 170cc7b

Browse files
authored
[DOCS] Add docs for restoring to new cluster (#79683) (#79875)
When restoring a snapshot to a new cluster, users may expect the cluster to not contain any conflicting indices or data streams. However, some features, such as the GeoIP processor, automatically create indices at startup. This adds and updates related procedures in the restore a snapshot tutorial. I plan to improve other documentation related to feature states in snapshots in a separate PR(s). This PR also updates the restore snapshot API's example to include the `indices` and `feature_states` parameters. Relates to #79675
1 parent 684afab commit 170cc7b

File tree

2 files changed

+168
-36
lines changed

2 files changed

+168
-36
lines changed

docs/reference/snapshot-restore/apis/restore-snapshot-api.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ POST /index_4/_close?wait_for_active_shards=0
5353
[source,console]
5454
----
5555
POST /_snapshot/my_repository/my_snapshot/_restore
56+
{
57+
"indices": "*,-.*",
58+
"feature_states": [ "geoip" ]
59+
}
5660
----
5761
// TEST[s/_restore/_restore?wait_for_completion=true/]
62+
// TEST[s/",/"/]
63+
// TEST[s/"feature_states": \[ "geoip" \]//]
5864

5965
[[restore-snapshot-api-request]]
6066
==== {api-request-title}

docs/reference/snapshot-restore/restore-snapshot.asciidoc

Lines changed: 162 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ In this guide, you'll learn how to:
1010

1111
* Get a list of available snapshots
1212
* Restore an index or data stream from a snapshot
13+
* Restore a feature state
1314
* Restore an entire cluster
1415
* Monitor the restore operation
1516
* Cancel an ongoing restore
@@ -33,7 +34,7 @@ When restoring data from a snapshot, keep the following in mind:
3334
* If you restore a data stream, you also restore its backing indices.
3435

3536
* You can only restore an existing index if it's <<indices-close,closed>> and
36-
the index in the snapshot has the same number of primary shards.
37+
the index in the snapshot has the same number of primary shards.
3738

3839
* You can't restore an existing open index. This includes
3940
backing indices for a data stream.
@@ -79,15 +80,21 @@ GET _snapshot/my_repository/*?verbose=false
7980
You can restore a snapshot using {kib}'s *Snapshot and Restore* feature or the
8081
<<restore-snapshot-api,restore snapshot API>>.
8182

82-
In most cases, you only need to restore a specific index or data stream from a
83-
snapshot. However, you can't restore an existing open index.
83+
By default, a restore request attempts to restore all indices and data streams
84+
in a snapshot, including <<system-indices,system indices and system data
85+
streams>>. In most cases, you only need to restore a specific index or data
86+
stream from a snapshot. However, you can't restore an existing open index.
8487

85-
To avoid conflicts with existing indices and data streams, use one of the
86-
following methods:
88+
If you're restoring data to a pre-existing cluster, use one of the
89+
following methods to avoid conflicts with existing indices and data streams:
8790

8891
* <<delete-restore>>
8992
* <<rename-on-restore>>
9093

94+
Some {es} features automatically create system indices on cluster startup. To
95+
avoid conflicts with these system indices when restoring data to a new cluster,
96+
see <<restore-exclude-system-indices>>.
97+
9198
[discrete]
9299
[[delete-restore]]
93100
==== Delete and restore
@@ -113,18 +120,12 @@ DELETE _data_stream/logs-my_app-default
113120
----
114121
// TEST[setup:setup-snapshots]
115122

116-
By default, a restore request attempts to restore all indices and data
117-
streams in the snapshot, including system indices. If your cluster already
118-
contains one or more of these system indices, the request will return an error.
119-
120-
To avoid this error, specify the indices and data streams to restore. To exclude
121-
system indices and other index names that begin with a dot (`.`), append the
122-
`-.*` wildcard pattern. To restore all indices and data streams except dot
123-
indices, use `*,-.*`.
123+
In the restore request, explicitly specify any indices and data streams to
124+
restore.
124125

125126
[source,console]
126127
----
127-
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
128+
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
128129
{
129130
"indices": "my-index,logs-my_app-default"
130131
}
@@ -149,7 +150,7 @@ any restored index or data stream.
149150

150151
[source,console]
151152
----
152-
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
153+
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
153154
{
154155
"indices": "my-index,logs-my_app-default",
155156
"rename_pattern": "(.+)",
@@ -205,17 +206,94 @@ POST _reindex
205206
----
206207
// TEST[continued]
207208

209+
[discrete]
210+
[[restore-exclude-system-indices]]
211+
==== Exclude system indices
212+
213+
Some {es} features, such as the <<geoip-processor,GeoIP processor>>,
214+
automatically create system indices at startup. To avoid naming conflicts with
215+
these indices, use the `-.*` wildcard pattern to exclude system indices and
216+
other dot (`.`) indices from your restore request.
217+
218+
For example, the following request uses the `*,-.*` wildcard pattern to restore
219+
all indices and data streams except dot indices.
220+
221+
[source,console]
222+
----
223+
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
224+
{
225+
"indices": "*,-.*"
226+
}
227+
----
228+
// TEST[setup:setup-snapshots]
229+
// TEST[s/^/DELETE my-index\nDELETE _data_stream\/logs-my_app-default\n/]
230+
// TEST[s/_restore/_restore?wait_for_completion=true/]
231+
232+
[discrete]
233+
[[restore-feature-state]]
234+
=== Restore a feature state
235+
236+
You can restore a feature state to recover system indices, system data streams,
237+
and other configuration data for a feature from a snapshot. Restoring a feature
238+
state is the preferred way to restore system indices and system data streams.
239+
240+
If you restore a snapshot's cluster state, the operation restores all feature
241+
states in the snapshot by default. Similarly, if you don't restore a snapshot's
242+
cluster state, the operation doesn't restore any feature states by default. You
243+
can also choose to restore only specific feature states from a snapshot,
244+
regardless of the cluster state.
245+
246+
To view a snapshot's feature states, use the get snapshot API.
247+
248+
[source,console]
249+
----
250+
GET _snapshot/my_repository/my_snapshot_2099.05.06
251+
----
252+
// TEST[setup:setup-snapshots]
253+
254+
The response's `feature_states` property contains a list of features in the
255+
snapshot as well as each feature's indices.
256+
257+
To restore a specific feature state from the snapshot, specify the
258+
`feature_name` from the response in the restore snapshot API's
259+
<<restore-snapshot-api-feature-states,`feature_states`>> parameter. When you
260+
restore a feature state, {es} closes and overwrites the feature's existing
261+
indices.
262+
263+
WARNING: Restoring the `security` feature state overwrites system indices
264+
used for authentication. If you use {ess}, ensure you have access to the {ess}
265+
Console before restoring the `security` feature state. If you run {es} on your
266+
own hardware, <<restore-create-file-realm-user,create a superuser in the file
267+
realm>> to ensure you'll still be able to access your cluster.
268+
269+
To avoid accidentally restoring system indices, system data streams, and other
270+
dot indices, append the `-.*` wildcard pattern to the `indices` value.
271+
272+
[source,console]
273+
----
274+
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
275+
{
276+
"indices": "*,-.*",
277+
"feature_states": [ "geoip" ]
278+
}
279+
----
280+
// TEST[setup:setup-snapshots]
281+
// TEST[s/^/DELETE my-index\nDELETE _data_stream\/logs-my_app-default\n/]
282+
// TEST[s/_restore/_restore?wait_for_completion=true/]
283+
// TEST[s/",/"/]
284+
// TEST[s/"feature_states": \[ "geoip" \]//]
285+
208286
[discrete]
209287
[[restore-entire-cluster]]
210288
=== Restore an entire cluster
211289

212290
In some cases, you need to restore an entire cluster from a snapshot, including
213-
the cluster state and all system indices. These cases should be rare, such as in
291+
the cluster state and all feature states. These cases should be rare, such as in
214292
the event of a catastrophic failure.
215293

216-
Restoring an entire cluster involves deleting important system indices, including
217-
those used for authentication. Consider whether you can restore specific indices
218-
or data streams instead.
294+
Restoring an entire cluster involves deleting important system indices,
295+
including those used for authentication. Consider whether you can restore
296+
specific indices or data streams instead.
219297

220298
If you're restoring to a different cluster, see <<restore-different-cluster>>
221299
before you start.
@@ -235,6 +313,18 @@ the cluster.
235313
. Temporarily stop indexing and turn off the following features:
236314
+
237315
--
316+
* GeoIP database downloader
317+
+
318+
[source,console]
319+
----
320+
PUT _cluster/settings
321+
{
322+
"persistent": {
323+
"ingest.geoip.downloader.enabled": false
324+
}
325+
}
326+
----
327+
238328
* ILM
239329
+
240330
[source,console]
@@ -265,19 +355,18 @@ POST _ml/set_upgrade_mode?enabled=false
265355
// TEST[continued]
266356
////
267357

268-
////
358+
* Monitoring
359+
+
269360
[source,console]
270361
----
271362
PUT _cluster/settings
272363
{
273364
"persistent": {
274-
"xpack.monitoring.collection.enabled": true
365+
"xpack.monitoring.collection.enabled": false
275366
}
276367
}
277368
----
278369
// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
279-
// TEST[continued]
280-
////
281370

282371
* Watcher
283372
+
@@ -295,23 +384,29 @@ POST _watcher/_start
295384
////
296385
--
297386

298-
. If you use {es} security features, log in to a node host, navigate to the {es}
387+
388+
. {blank}
389+
+
390+
--
391+
[[restore-create-file-realm-user]]
392+
If you use {es} security features, log in to a node host, navigate to the {es}
299393
installation directory, and add a user with the `superuser` role to the file
300394
realm using the <<users-command,`elasticsearch-users`>> tool.
301-
+
395+
302396
For example, the following command creates a user named `restore_user`.
303-
+
397+
304398
[source,sh]
305399
----
306400
./bin/elasticsearch-users useradd restore_user -p my_password -r superuser
307401
----
308-
+
402+
309403
Use this file realm user to authenticate requests until the restore operation is
310404
complete.
405+
--
311406

312407
. Use the <<cluster-update-settings,cluster update settings API>> to set
313408
<<action-destructive-requires-name,`action.destructive_requires_name`>> to
314-
`false`. This lets you delete indices and data streams using wildcards.
409+
`false`. This lets you delete data streams and indices using wildcards.
315410
+
316411
[source,console]
317412
----
@@ -324,24 +419,28 @@ PUT _cluster/settings
324419
----
325420
// TEST[setup:setup-snapshots]
326421

327-
. Delete existing indices and data streams on the cluster.
422+
. Delete all existing data streams on the cluster.
328423
+
329424
[source,console]
330425
----
331-
# Delete all indices
332-
DELETE *
426+
DELETE _data_stream/*?expand_wildcards=all
427+
----
428+
// TEST[continued]
333429

334-
# Delete all data streams
335-
DELETE _data_stream/*
430+
. Delete all existing indices on the cluster.
431+
+
432+
[source,console]
433+
----
434+
DELETE *?expand_wildcards=all
336435
----
337436
// TEST[continued]
338437

339-
. Restore the entire snapshot, including the cluster state. This also restores
340-
any system indices in the snapshot.
438+
. Restore the entire snapshot, including the cluster state. By default,
439+
restoring the cluster state also restores any feature states in the snapshot.
341440
+
342441
[source,console]
343442
----
344-
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
443+
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
345444
{
346445
"indices": "*",
347446
"include_global_state": true
@@ -354,6 +453,19 @@ POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
354453
features you stopped:
355454
+
356455
--
456+
* GeoIP database downloader
457+
+
458+
[source,console]
459+
----
460+
PUT _cluster/settings
461+
{
462+
"persistent": {
463+
"ingest.geoip.downloader.enabled": true
464+
}
465+
}
466+
----
467+
//TEST[s/true/false/]
468+
357469
* ILM
358470
+
359471
[source,console]
@@ -368,6 +480,20 @@ POST _ilm/start
368480
POST _ml/set_upgrade_mode?enabled=false
369481
----
370482

483+
* Monitoring
484+
+
485+
[source,console]
486+
----
487+
PUT _cluster/settings
488+
{
489+
"persistent": {
490+
"xpack.monitoring.collection.enabled": true
491+
}
492+
}
493+
----
494+
// TEST[warning:[xpack.monitoring.collection.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
495+
// TEST[s/true/false/]
496+
371497
* Watcher
372498
+
373499
[source,console]

0 commit comments

Comments
 (0)