Skip to content

Commit 2fc3d40

Browse files
authored
[DOCS] Convert 'Restore a snapshot' to tutorial (#76929)
Updates the 'Restore a snapshot' guide to be more tutorial-focused. Adds a tutorial for restoring an entire cluster. Closes #72497.
1 parent f3f11ab commit 2fc3d40

File tree

9 files changed

+541
-335
lines changed

9 files changed

+541
-335
lines changed

docs/build.gradle

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,29 @@ setups['setup-repository'] = '''
15151515
location: buildDir/cluster/shared/repo
15161516
'''
15171517

1518+
// Used by snapshot restore docs
1519+
setups['setup-snapshots'] = setups['setup-repository'] + '''
1520+
- do:
1521+
bulk:
1522+
index: my-index
1523+
refresh: true
1524+
body: |
1525+
{"index":{"_id": "0"}}
1526+
{"message": "trying out Elasticsearch", "context": "foo"}
1527+
- do:
1528+
bulk:
1529+
index: logs-my_app-default
1530+
refresh: true
1531+
body: |
1532+
{"create":{"_id": "0"}}
1533+
{"message": "trying out Elasticsearch", "context": "foo"}
1534+
- do:
1535+
snapshot.create:
1536+
repository: my_repository
1537+
snapshot: my_snapshot_2099.05.06
1538+
wait_for_completion: true
1539+
'''
1540+
15181541
// Fake sec logs data used by EQL search
15191542
setups['atomic_red_regsvr32'] = setups['my_data_stream'] + '''
15201543
- do:

docs/reference/high-availability/backup-and-restore-security-config.asciidoc

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -162,115 +162,3 @@ of the users in the native realm and revoke API keys.
162162
* If there are indications that the snapshot has been tampered with, do not
163163
restore it. There is currently no option for the restore process to detect
164164
malicious tampering.
165-
166-
[[restore-security-configuration]]
167-
=== Restore a cluster's security configuration
168-
++++
169-
<titleabbrev>Restore the security configuration</titleabbrev>
170-
++++
171-
172-
NOTE: You can restore a snapshot of the `.security` index only if it was
173-
created in a previous minor version in the same major version. The last minor
174-
version of every major release can convert and read formats of the index for
175-
both its major version and the next one.
176-
177-
When you restore security configuration you have the option of doing a complete
178-
restore of *all* configurations, including non-security ones, or to only restore
179-
the contents of the `.security` index. As described in
180-
<<backup-security-index-configuration>>, the second option comprises only
181-
resource-type configurations. The first option has the advantage of restoring
182-
a cluster to a clearly defined state from a past point in time. The second option
183-
touches only security configuration resources, but it does not completely restore
184-
the {security-features}.
185-
186-
To restore your security configuration from a backup, first make sure that the
187-
repository holding `.security` snapshots is installed:
188-
189-
[source,console]
190-
--------------------------------------------------
191-
GET /_snapshot/my_backup
192-
--------------------------------------------------
193-
// TEST[continued]
194-
195-
[source,console]
196-
--------------------------------------------------
197-
GET /_snapshot/my_backup/snapshot_1
198-
--------------------------------------------------
199-
// TEST[continued]
200-
201-
Then log in to one of the node hosts, navigate to {es} installation directory,
202-
and follow these steps:
203-
204-
. Add a new user with the `superuser` built-in role to the
205-
<<file-realm,file realm>>.
206-
+
207-
--
208-
For example, create a user named `restore_user`:
209-
[source,shell]
210-
--------------------------------------------------
211-
bin/elasticsearch-users useradd restore_user -p password -r superuser
212-
--------------------------------------------------
213-
--
214-
215-
. Using the previously created user, delete the existing `.security-6` or
216-
`.security-7` index.
217-
+
218-
--
219-
[source,shell]
220-
--------------------------------------------------
221-
curl -u restore_user -X DELETE "localhost:9200/.security-*"
222-
--------------------------------------------------
223-
// NOTCONSOLE
224-
225-
WARNING: After this step any authentication that relies on the `.security`
226-
index will not work. This means that all API calls that authenticate with
227-
native or reserved users will fail, as will any user that relies on a native role.
228-
The file realm user we created in the step above will continue to work
229-
because it is not stored in the `.security` index and uses the built-in
230-
`superuser` role.
231-
232-
--
233-
234-
. Using the same user, restore the `.security` index from the snapshot.
235-
+
236-
--
237-
[source,shell]
238-
--------------------------------------------------
239-
curl -u restore_user -X POST "localhost:9200/_snapshot/my_backup/snapshot_1/_restore" -H 'Content-Type: application/json' -d'
240-
{
241-
"indices": ".security-*",
242-
"include_global_state": true <1>
243-
}
244-
'
245-
--------------------------------------------------
246-
// NOTCONSOLE
247-
248-
<1> The `include_global_state: true` is mandatory only for a complete restore.
249-
This will restore the global cluster metadata, which contains configuration
250-
information for the complete cluster. If you set this to `false`, it recovers
251-
only the contents of the `.security` index, such as usernames and password
252-
hashes, API keys, application privileges, role and role mapping definitions.
253-
--
254-
255-
. Optionally, if you need to review and override the settings that were included
256-
in the snapshot (by the `include_global_state` flag), cherry-pick and
257-
<<cluster-update-settings,apply the persistent settings>> that you
258-
<<backup-cluster-configuration, have extracted>> with the
259-
`GET _cluster/settings` API.
260-
261-
. If you pursue a complete point in time restore of the cluster, you also have
262-
to restore configuration files. Again, this will restore non-security settings as
263-
well.
264-
+
265-
--
266-
This entails a straight-up filesystem copy of the backed up configuration files,
267-
overwriting the contents of `$ES_PATH_CONF`, and restarting the node. This
268-
needs to be done on *every node*. Depending on the extent of the differences
269-
between your current cluster configuration and the restored configuration, you
270-
may not be able to perform a rolling restart. If you are performing a full
271-
restore of your configuration directory, we recommend a full cluster restart as
272-
the safest option. Alternatively, you may wish to restore your configuration
273-
files to a separate location on disk and use file comparison tools to review
274-
the differences between your existing configuration and the restored
275-
configuration.
276-
--

docs/reference/high-availability/backup-cluster.asciidoc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ To have a complete backup for your cluster:
99
. <<backup-cluster-configuration,Back up the cluster configuration>>
1010
. <<security-backup,Back up the security configuration>>
1111

12-
To restore your cluster from a backup:
13-
14-
. <<restore-cluster-data,Restore the data>>
15-
. <<restore-security-configuration,Restore the security configuration>>
12+
To restore your cluster from a backup, see <<restore-entire-cluster>>.
1613

1714

1815

1916
include::backup-cluster-data.asciidoc[]
2017
include::backup-cluster-config.asciidoc[]
2118
include::backup-and-restore-security-config.asciidoc[]
22-
include::restore-cluster-data.asciidoc[]

docs/reference/high-availability/restore-cluster-data.asciidoc

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/reference/redirects.asciidoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
The following pages have moved or been deleted.
55

6+
[role="exclude",id="restore-cluster-data"]
7+
=== Restore a cluster's data
8+
9+
See <<restore-entire-cluster>>.
610
[role="exclude",id="alias"]
711
=== Aliases
812

@@ -767,7 +771,7 @@ See <<snapshots-repository-plugins>>.
767771
[role="exclude",id="_changing_index_settings_during_restore"]
768772
==== Change index settings during restore
769773

770-
See <<change-index-settings-during-restore>>.
774+
See <<restore-snapshot-api-index-settings>>.
771775

772776
[role="exclude",id="restore-snapshot"]
773777
=== Restore snapshot

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

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,26 @@ POST /_snapshot/my_repository/my_snapshot/_restore
6464
[[restore-snapshot-api-prereqs]]
6565
==== {api-prereq-title}
6666

67-
* If the {es} {security-features} are enabled, you must have the `manage`
68-
<<privileges-list-cluster,cluster privilege>> to use this API.
67+
// tag::restore-prereqs[]
68+
* If you use the {es} security features, you must have the `manage` or
69+
`cluster:admin/snapshot/*` cluster privilege to restore a snapshot.
6970

70-
[[restore-snapshot-api-desc]]
71-
==== {api-description-title}
71+
* You can only restore a snapshot to a running cluster with an elected
72+
<<master-node,master node>>. The snapshot's repository must be
73+
<<snapshots-register-repository,registered>> and available to the cluster.
7274

73-
Use the restore snapshot API to restore a snapshot of a cluster, including all data streams and indices in the snapshot. If you do not want to restore the entire snapshot, you can select specific data streams or indices to restore.
75+
* The snapshot and cluster versions must be compatible. See
76+
<<snapshot-restore-version-compatibility>>.
7477

75-
You can run the restore operation on a cluster that contains an elected
76-
<<master-node,master node>> and has data nodes with enough capacity to accommodate the snapshot
77-
you are restoring. Existing indices can only be restored if they are
78-
<<indices-close,closed>> and have the same number of shards as the indices in
79-
the snapshot. The restore operation automatically opens restored indices if
80-
they were closed and creates new indices if they do not exist in the cluster.
78+
* If you restore a data stream, ensure the cluster contains a
79+
<<create-index-template,matching index template>> with data stream enabled.
80+
Without a matching index template, a data stream can't roll over or create
81+
backing indices.
8182

82-
If a data stream is restored, its aliases and backing indices are also restored.
83-
Alternatively, you can restore individual backing indices without restoring an
84-
entire data stream. If you restore individual backing indices, they are not
85-
automatically added to any existing data stream. For example, if only the
86-
`.ds-logs-2099.03.08-00003` backing index is restored from a snapshot, it is not
87-
automatically added to the existing `logs` data stream.
88-
89-
include::{es-ref-dir}/snapshot-restore/restore-snapshot.asciidoc[tag=index-settings-data-stream-warning]
83+
* If your snapshot contains data from App Search or Workplace Search, ensure
84+
you've restored the {enterprise-search-ref}/encryption-keys.html[Enterprise
85+
Search encryption key] before restoring the snapshot.
86+
// end::restore-prereqs[]
9087

9188
[[restore-snapshot-api-path-params]]
9289
==== {api-path-parms-title}
@@ -107,7 +104,7 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
107104
`wait_for_completion`::
108105
(Optional, Boolean) If `true`, the request returns a response when the restore
109106
operation completes. The operation is complete when it finishes all attempts to
110-
<<_monitoring_restore_operations,recover primary shards>> for restored indices.
107+
<<monitor-restore,recover primary shards>> for restored indices.
111108
This applies even if one or more of the recovery attempts fail.
112109
+
113110
If `false`, the request returns a response when the restore
@@ -118,14 +115,15 @@ operation initializes. Defaults to `false`.
118115
==== {api-request-body-title}
119116

120117
`ignore_unavailable`::
121-
(Optional, Boolean)
122-
If `false`, the request returns an error for any data stream or index that is missing or closed. Defaults to `false`.
123-
+
124-
If `true`, the request ignores data streams and indices in `indices` that are missing or closed.
118+
(Optional, Boolean) If `true`, the request ignores any index or data stream in
119+
`indices` that's missing from the snapshot. If `false`, the request returns an
120+
error for any missing index or data stream. Defaults to `false`.
125121

126122
`ignore_index_settings`::
127-
(Optional, string)
128-
A comma-separated list of index settings that should not be restored from a snapshot.
123+
(Optional, string or array of strings) Index settings to not restore from the snapshot. You can't use this option to ignore <<index-number-of-shards,`index.number_of_shards`>>.
124+
+
125+
For data streams, this option only applies to restored backing indices. New
126+
backing indices are configured using the data stream's matching index template.
129127

130128
`include_aliases`::
131129
(Optional, Boolean)
@@ -171,23 +169,15 @@ By default, all available feature states will be restored if `include_global_sta
171169

172170
[[restore-snapshot-api-index-settings]]
173171
`index_settings`::
174-
(Optional, string)
175-
A comma-separated list of settings to add or change in all restored indices. Use this parameter to override index settings when restoring snapshots.
172+
(Optional, object) Index settings to add or change in restored indices,
173+
including backing indices. You can't use this option to change
174+
<<index-number-of-shards,`index.number_of_shards`>>.
176175
+
177-
For data streams, these index settings are applied to the restored backing
178-
indices.
179-
+
180-
For more information regarding all the different index-level settings
181-
that you can specify, see
182-
<<index-modules,index modules>>.
176+
For data streams, this option only applies to restored backing indices. New
177+
backing indices are configured using the data stream's matching index template.
183178

184179
`indices`::
185-
(Optional, string)
186-
A comma-separated list of data streams and indices to restore from the snapshot.
187-
<<multi-index,Multi-index syntax>> is supported.
188-
+
189-
By default, a restore operation includes all data streams and indices in the snapshot. If this
190-
argument is provided, the restore operation only includes the specified data streams and indices.
180+
(Optional, string or array of strings) Comma-separated list of indices and data streams to restore. Supports <<api-multi-index,multi-target syntax>>. Defaults to all indices and data streams in the snapshot, including system indices.
191181

192182
[[restore-snapshot-api-partial]]
193183
`partial`::
@@ -205,10 +195,6 @@ Defines a rename pattern to apply to restored data streams and indices. Data str
205195
+
206196
The rename pattern is applied as defined by the regular expression that
207197
supports referencing the original text, according to the https://docs.oracle.com/javase/8/docs/api/java/util/regex/Matcher.html#appendReplacement-java.lang.StringBuffer-java.lang.String-[`appendReplacement`] logic.
208-
+
209-
The request will fail if two or more data streams or indices will be renamed into the same name.
210-
+
211-
include::{es-ref-dir}/snapshot-restore/restore-snapshot.asciidoc[tag=rename-restored-data-stream-tag]
212198

213199
[[restore-snapshot-api-rename-replacement]]
214200
`rename_replacement`::

docs/reference/snapshot-restore/index.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ understand the time requirements before proceeding.
118118

119119
include::register-repository.asciidoc[]
120120
include::take-snapshot.asciidoc[]
121-
include::restore-snapshot.asciidoc[]
122121
include::monitor-snapshot-restore.asciidoc[]
123122
include::delete-snapshot.asciidoc[]
123+
include::restore-snapshot.asciidoc[]
124124
include::../slm/index.asciidoc[]
125125
include::../searchable-snapshots/index.asciidoc[]

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[[snapshots-monitor-snapshot-restore]]
2-
== Monitor snapshot and restore progress
3-
++++
4-
<titleabbrev>Monitor snapshot and restore</titleabbrev>
5-
++++
2+
== Monitor snapshot progress
63

74
Use the <<get-snapshot-api,get snapshot API>> or the
85
<<get-snapshot-status-api,get snapshot status API>> to monitor the
@@ -132,25 +129,9 @@ if not currently running:
132129
GET /_snapshot/my_backup/snapshot_1/_status
133130
-----------------------------------
134131

135-
[discrete]
136-
=== Monitoring restore operations
137-
138-
The restore process piggybacks on the standard recovery mechanism of
139-
{es}. As a result, standard recovery monitoring services can be used
140-
to monitor the state of restore. When the restore operation starts, the
141-
cluster typically goes into `yellow` state because the restore operation works
142-
by recovering primary shards of the restored indices. After the recovery of the
143-
primary shards is completed, {es} switches to the standard replication
144-
process that creates the required number of replicas. When all required
145-
replicas are created, the cluster switches to the `green` states.
146-
147-
The cluster health operation provides only a high level status of the restore process. It's possible to get more
148-
detailed insight into the current state of the recovery process by using <<indices-recovery, index recovery>> and
149-
<<cat-recovery, cat recovery>> APIs.
150-
151132
[discrete]
152133
[[get-snapshot-stop-snapshot]]
153-
=== Stop snapshot and restore operations
134+
=== Stop snapshot operations
154135
To stop a currently running snapshot that was started by mistake or is taking unusually long, use
155136
the <<delete-snapshot-api,delete snapshot API>>.
156137
This operation checks whether the deleted snapshot is currently running. If it is, the delete snapshot operation stops
@@ -161,10 +142,6 @@ that snapshot before deleting the snapshot data from the repository.
161142
DELETE /_snapshot/my_backup/snapshot_1
162143
-----------------------------------
163144

164-
The restore operation uses the standard shard recovery mechanism. Therefore, any currently running restore operation can
165-
be canceled by deleting data streams and indices that are being restored. Data for all deleted data streams and indices will be removed
166-
from the cluster as a result of this operation.
167-
168145
[discrete]
169146
[[get-snapshot-cluster-blocks]]
170147
=== Effect of cluster blocks on snapshot and restore

0 commit comments

Comments
 (0)