2019-06-07 20:28:01 +02:00
|
|
|
|
[role="xpack"]
|
|
|
|
|
[[snapshot-repositories]]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
== Snapshot and Restore
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
*Snapshot and Restore* enables you to backup your {es}
|
|
|
|
|
indices and clusters using data and state snapshots.
|
|
|
|
|
Snapshots are important because they provide a copy of your data in case
|
|
|
|
|
something goes wrong. If you need to roll back to an older version of your data,
|
|
|
|
|
you can restore a snapshot from the repository.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
You’ll find *Snapshot and Restore* under *Management > Elasticsearch*.
|
|
|
|
|
With this UI, you can:
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
* Register a repository for storing your snapshots
|
|
|
|
|
* View a list of your snapshots and drill down into details
|
|
|
|
|
* Restore data into your cluster from a snapshot
|
|
|
|
|
* Create a policy to automate snapshot creation and deletion
|
|
|
|
|
* Delete a snapshot to free storage space
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
[role="screenshot"]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
image:management/snapshot-restore/images/snapshot_list.png["Snapshot list"]
|
|
|
|
|
|
|
|
|
|
Before using this feature, you should be familiar with how snapshots work.
|
2020-01-10 01:12:15 +01:00
|
|
|
|
{ref}/snapshot-restore.html[Snapshot and Restore] is a good source for
|
2019-07-12 20:29:57 +02:00
|
|
|
|
more detailed information.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
[float]
|
2019-07-18 18:12:43 +02:00
|
|
|
|
[[kib-snapshot-register-repository]]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
=== Register a repository
|
2019-10-25 22:27:55 +02:00
|
|
|
|
A repository is where your snapshots live. You must register a snapshot
|
|
|
|
|
repository before you can perform snapshot and restore operations.
|
|
|
|
|
|
|
|
|
|
If you don't have a repository, Kibana walks you through the process of
|
|
|
|
|
registering one.
|
|
|
|
|
{kib} supports three repository types
|
|
|
|
|
out of the box: shared file system, read-only URL, and source-only.
|
|
|
|
|
For more information on these repositories and their settings,
|
2020-01-10 01:12:15 +01:00
|
|
|
|
see {ref}/snapshots-register-repository.html[Repositories].
|
2019-10-25 22:27:55 +02:00
|
|
|
|
To use other repositories, such as S3, see
|
2020-01-10 01:12:15 +01:00
|
|
|
|
{ref}/snapshots-register-repository.html#snapshots-repository-plugins[Repository plugins].
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
|
|
|
|
|
Once you create a repository, it is listed in the *Repositories*
|
|
|
|
|
view.
|
|
|
|
|
Click a repository name to view its type, number of snapshots, and settings,
|
|
|
|
|
and to verify status.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
[role="screenshot"]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
image:management/snapshot-restore/images/repository_list.png["Repository list"]
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[float]
|
2019-07-18 18:12:43 +02:00
|
|
|
|
[[kib-view-snapshot]]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
=== View your snapshots
|
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
A snapshot is a backup taken from a running {es} cluster. You'll find an overview of
|
|
|
|
|
your snapshots in the *Snapshots* view, and you can drill down
|
2019-07-12 20:29:57 +02:00
|
|
|
|
into each snapshot for further investigation.
|
|
|
|
|
|
|
|
|
|
[role="screenshot"]
|
|
|
|
|
image:management/snapshot-restore/images/snapshot_details.png["Snapshot details"]
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-09-14 00:38:30 +02:00
|
|
|
|
If you don’t have any snapshots, you can create them from the {kib} <<console-kibana, Console>>. The
|
2020-01-10 01:12:15 +01:00
|
|
|
|
{ref}/snapshots-take-snapshot.html[snapshot API]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
takes the current state and data in your index or cluster, and then saves it to a
|
2019-06-07 20:28:01 +02:00
|
|
|
|
shared repository.
|
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
The snapshot process is "smart." Your first snapshot is a complete copy of
|
|
|
|
|
the data in your index or cluster.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
All subsequent snapshots save the changes between the existing snapshots and
|
|
|
|
|
the new data.
|
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
[float]
|
2019-07-18 18:12:43 +02:00
|
|
|
|
[[kib-restore-snapshot]]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
=== Restore a snapshot
|
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
The information stored in a snapshot is not tied to a specific
|
|
|
|
|
cluster or a cluster name. This enables you to
|
|
|
|
|
restore a snapshot made from one cluster to another cluster. You might
|
|
|
|
|
use the restore operation to:
|
2019-09-14 00:38:30 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
* Recover data lost due to a failure
|
|
|
|
|
* Migrate a current Elasticsearch cluster to a new version
|
|
|
|
|
* Move data from one cluster to another cluster
|
|
|
|
|
|
|
|
|
|
To get started, go to the *Snapshots* view, find the
|
|
|
|
|
snapshot, and click the restore icon in the *Actions* column.
|
|
|
|
|
The Restore wizard presents
|
|
|
|
|
options for the restore operation, including which
|
2019-07-12 20:29:57 +02:00
|
|
|
|
indices to restore and whether to modify the index settings.
|
2019-09-14 00:38:30 +02:00
|
|
|
|
You can restore an existing index only if it’s closed and has the same
|
|
|
|
|
number of shards as the index in the snapshot.
|
2019-07-12 20:29:57 +02:00
|
|
|
|
|
2019-09-14 00:38:30 +02:00
|
|
|
|
Once you initiate the restore, you're navigated to the *Restore Status* view,
|
2019-10-25 22:27:55 +02:00
|
|
|
|
where you can track the current state for each shard in the snapshot.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
[role="screenshot"]
|
2019-09-14 00:38:30 +02:00
|
|
|
|
image:management/snapshot-restore/images/snapshot-restore.png["Snapshot details"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[float]
|
|
|
|
|
[[kib-snapshot-policy]]
|
|
|
|
|
=== Create a snapshot lifecycle policy
|
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
Use a {ref}/snapshot-lifecycle-management-api.html[snapshot lifecycle policy]
|
|
|
|
|
to automate the creation and deletion
|
|
|
|
|
of cluster snapshots. Taking automatic snapshots:
|
|
|
|
|
|
|
|
|
|
* Ensures your {es} indices and clusters are backed up on a regular basis
|
|
|
|
|
* Ensures a recent and relevant snapshot is available if a situation
|
|
|
|
|
arises where a cluster needs to be recovered
|
|
|
|
|
* Allows you to manage your snapshots in {kib}, instead of using a
|
|
|
|
|
third-party tool
|
|
|
|
|
|
|
|
|
|
If you don’t have any snapshot policies, follow the
|
|
|
|
|
*Create policy* wizard. It walks you through defining
|
|
|
|
|
when and where to take snapshots, the settings you want,
|
|
|
|
|
and how long to retain snapshots.
|
2019-09-14 00:38:30 +02:00
|
|
|
|
|
|
|
|
|
[role="screenshot"]
|
2019-10-25 22:27:55 +02:00
|
|
|
|
image:management/snapshot-restore/images/snapshot-retention.png["Snapshot details"]
|
|
|
|
|
|
|
|
|
|
An overview of your policies is on the *Policies* view.
|
|
|
|
|
You can drill down into each policy to examine its settings and last successful and failed run.
|
2019-09-14 00:38:30 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
You can perform the following actions on a snapshot policy:
|
2019-09-14 00:38:30 +02:00
|
|
|
|
|
|
|
|
|
* *Run* a policy immediately without waiting for the scheduled time.
|
|
|
|
|
This action is useful before an upgrade or before performing maintenance on indices.
|
|
|
|
|
* *Edit* a policy and immediately apply changes to the schedule.
|
|
|
|
|
* *Delete* a policy to prevent any future snapshots from being taken.
|
|
|
|
|
This action does not cancel any currently ongoing snapshots or remove any previously taken snapshots.
|
2019-07-12 20:29:57 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
[role="screenshot"]
|
|
|
|
|
image:management/snapshot-restore/images/create-policy.png["Snapshot details"]
|
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
[float]
|
2019-07-18 18:12:43 +02:00
|
|
|
|
[[kib-delete-snapshot]]
|
2019-07-12 20:29:57 +02:00
|
|
|
|
=== Delete a snapshot
|
|
|
|
|
|
|
|
|
|
Delete snapshots to manage your repository storage space.
|
|
|
|
|
Find the snapshot in the *Snapshots* view and click the trash icon in the
|
|
|
|
|
*Actions* column. To delete snapshots in bulk, select their checkboxes,
|
|
|
|
|
and then click *Delete snapshots*.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
[[snapshot-repositories-example]]
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
[role="xpack"]
|
|
|
|
|
[[snapshot-restore-tutorial]]
|
|
|
|
|
=== Tutorial: Snapshot and Restore
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
Ready to try *Snapshot and Restore*? In this tutorial, you'll learn to:
|
|
|
|
|
|
|
|
|
|
* Register a repository
|
|
|
|
|
* Add snapshots to the repository
|
|
|
|
|
* Create a snapshot lifecycle policy
|
|
|
|
|
* Restore a snapshot
|
|
|
|
|
|
|
|
|
|
==== Before you begin
|
|
|
|
|
|
|
|
|
|
This example shows you how to register a shared file system repository
|
|
|
|
|
and store snapshots.
|
|
|
|
|
Before you begin, you must register the location of the repository in the
|
2020-01-10 01:12:15 +01:00
|
|
|
|
{ref}/snapshots-register-repository.html#snapshots-filesystem-repository[path.repo] setting on
|
2019-06-07 20:28:01 +02:00
|
|
|
|
your master and data nodes. You can do this in one of two ways:
|
|
|
|
|
|
|
|
|
|
* Edit your `elasticsearch.yml` to include the `path.repo` setting.
|
|
|
|
|
|
|
|
|
|
* Pass the `path.repo` setting when you start Elasticsearch.
|
|
|
|
|
+
|
|
|
|
|
`bin/elasticsearch -E path.repo=/tmp/es-backups`
|
|
|
|
|
|
|
|
|
|
[float]
|
2019-10-25 22:27:55 +02:00
|
|
|
|
[[register-repo-example]]
|
|
|
|
|
==== Register a repository
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
Use *Snapshot and Restore* to register the repository where your snapshots
|
|
|
|
|
will live.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-07-12 20:29:57 +02:00
|
|
|
|
. Go to *Management > Elasticsearch > Snapshot and Restore*.
|
2019-10-25 22:27:55 +02:00
|
|
|
|
. Click *Register a repository* in either the introductory message or *Repository view*.
|
2019-09-14 00:38:30 +02:00
|
|
|
|
. Enter a name for your repository, for example, `my_backup`.
|
2019-10-25 22:27:55 +02:00
|
|
|
|
. Select *Shared file system*.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
+
|
|
|
|
|
[role="screenshot"]
|
|
|
|
|
image:management/snapshot-restore/images/register_repo.png["Register repository"]
|
|
|
|
|
|
|
|
|
|
. Click *Next*.
|
2019-10-25 22:27:55 +02:00
|
|
|
|
. In *File system location*, enter the path to the snapshot repository, `/tmp/es-backups`.
|
|
|
|
|
. In *Chunk size*, enter `100mb` so that snapshot files are not bigger than that size.
|
|
|
|
|
. Use the defaults for all other fields, and then click *Register*.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
+
|
2019-09-14 00:38:30 +02:00
|
|
|
|
Your new repository is listed on the *Repositories* view.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
The repository currently doesn’t have any snapshots.
|
2019-07-12 20:29:57 +02:00
|
|
|
|
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
[float]
|
|
|
|
|
==== Add a snapshot to the repository
|
2020-01-10 01:12:15 +01:00
|
|
|
|
Use the {ref}/snapshots-take-snapshot.html[snapshot API] to create a snapshot.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
|
|
|
|
. Go to *Dev Tools > Console*.
|
2019-10-25 22:27:55 +02:00
|
|
|
|
. Create the snapshot:
|
|
|
|
|
+
|
|
|
|
|
[source,js]
|
|
|
|
|
PUT /_snapshot/my_backup/2019-04-25_snapshot?wait_for_completion=true
|
2019-06-07 20:28:01 +02:00
|
|
|
|
+
|
|
|
|
|
In this example, the snapshot name is `2019-04-25_snapshot`. You can also
|
2020-01-10 01:12:15 +01:00
|
|
|
|
use {ref}/date-math-index-names.html[date math expression] for the snapshot name.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
+
|
|
|
|
|
[role="screenshot"]
|
|
|
|
|
image:management/snapshot-restore/images/create_snapshot.png["Create snapshot"]
|
2019-10-25 22:27:55 +02:00
|
|
|
|
|
|
|
|
|
. Return to *Snapshot and Restore*.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
+
|
2019-07-12 20:29:57 +02:00
|
|
|
|
Your new snapshot is available in the *Snapshots* view.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
[[create-policy-example]]
|
|
|
|
|
==== Create a snapshot lifecycle policy
|
|
|
|
|
|
|
|
|
|
Now you'll automate the creation and deletion of snapshots
|
|
|
|
|
using the repository created in the previous example.
|
|
|
|
|
|
|
|
|
|
. Open the *Policies* view.
|
|
|
|
|
. Click *Create a policy*.
|
|
|
|
|
+
|
|
|
|
|
[role="screenshot"]
|
|
|
|
|
image:management/snapshot-restore/images/create-policy-example.png["Create policy wizard"]
|
|
|
|
|
|
|
|
|
|
. As you walk through the wizard, enter the following values:
|
|
|
|
|
+
|
|
|
|
|
|===
|
|
|
|
|
|*Logistics* |
|
|
|
|
|
|
|
|
|
|
|Policy name
|
|
|
|
|
|`daily-snapshots`
|
|
|
|
|
|
|
|
|
|
|Snapshot name
|
|
|
|
|
|`<daily-snap-{now/d}>`
|
|
|
|
|
|
|
|
|
|
|Schedule
|
|
|
|
|
|Every day at 1:30 a.m.
|
|
|
|
|
|
|
|
|
|
|Repository
|
|
|
|
|
|`my_backup`
|
|
|
|
|
|
|
|
|
|
|*Snapshot settings* |
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
|Indices
|
|
|
|
|
|Select the indices to back up. By default, all indices, including system indices, are backed up.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
|All other settings
|
|
|
|
|
|Use the defaults.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|
2019-10-25 22:27:55 +02:00
|
|
|
|
|*Snapshot retention* |
|
|
|
|
|
|
|
|
|
|
|Expiration
|
|
|
|
|
|`30 days`
|
|
|
|
|
|
|
|
|
|
|Snapshots to retain
|
|
|
|
|
|Minimum count: `5`, Maximum count: `50`
|
|
|
|
|
|===
|
|
|
|
|
|
|
|
|
|
. Review your input, and then click *Create policy*.
|
|
|
|
|
+
|
|
|
|
|
Your new policy is listed in the *Policies* view, and you see a summary of its details.
|
|
|
|
|
|
|
|
|
|
[[restore-snapshot-example]]
|
|
|
|
|
==== Restore a snapshot
|
|
|
|
|
Finally, you'll restore indices from an existing snapshot.
|
|
|
|
|
|
|
|
|
|
. In the *Snapshots* view, find the snapshot you want to restore, for example `2019-04-25_snapshot`.
|
|
|
|
|
. Click the restore icon in the *Actions* column.
|
|
|
|
|
. As you walk through the wizard, enter the following values:
|
|
|
|
|
+
|
|
|
|
|
|===
|
|
|
|
|
|*Logistics* |
|
|
|
|
|
|
|
|
|
|
|Indices
|
|
|
|
|
|Toggle to choose specific indices to restore, or leave in place to restore all indices.
|
|
|
|
|
|
|
|
|
|
|Rename indices
|
|
|
|
|
|Toggle to give your restored indices new names, or leave in place to restore under original index names.
|
|
|
|
|
|
|
|
|
|
|All other fields
|
|
|
|
|
|Use the defaults.
|
|
|
|
|
|
|
|
|
|
|*Index settings* |
|
|
|
|
|
|
|
|
|
|
|Modify index settings
|
|
|
|
|
|Toggle to overwrite index settings when they are restored,
|
|
|
|
|
or leave in place to keep existing settings.
|
|
|
|
|
|
|
|
|
|
|Reset index settings
|
|
|
|
|
|Toggle to reset index settings back to the default when they are restored,
|
|
|
|
|
or leave in place to keep existing settings.
|
|
|
|
|
|===
|
|
|
|
|
|
|
|
|
|
. Review your restore settings, and then click *Restore snapshot*.
|
|
|
|
|
+
|
|
|
|
|
The operation loads for a few seconds,
|
|
|
|
|
and then you’re navigated to *Restore Status*,
|
|
|
|
|
where you can monitor the status of your restored indices.
|
2019-06-07 20:28:01 +02:00
|
|
|
|
|