Tutorial: Snapshot and Restore
editTutorial: Snapshot and Restore
editReady 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
editThis 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 path.repo setting on your master and data nodes. You can do this in one of two ways:
-
Edit your
elasticsearch.yml
to include thepath.repo
setting. -
Pass the
path.repo
setting when you start Elasticsearch.bin/elasticsearch -E path.repo=/tmp/es-backups
Register a repository
editUse Snapshot and Restore to register the repository where your snapshots will live.
- Open the main menu, then click Stack Management > Snapshot and Restore.
- Click Register a repository in either the introductory message or Repository view.
-
Enter a name for your repository, for example,
my_backup
. -
Select Shared file system.
- Click Next.
-
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.
Your new repository is listed on the Repositories view. The repository currently doesn’t have any snapshots.
Add a snapshot to the repository
editUse the snapshot API to create a snapshot.
- Open the main menu, click Dev Tools, then select Console.
-
Create the snapshot:
PUT /_snapshot/my_backup/2019-04-25_snapshot?wait_for_completion=true
In this example, the snapshot name is
2019-04-25_snapshot
. You can also use date math expression for the snapshot name. -
Return to Snapshot and Restore.
Your new snapshot is available in the Snapshots view.
Create a snapshot lifecycle policy
editNow 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.
-
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
Indices
Select the indices to back up. By default, all indices, including system indices, are backed up.
All other settings
Use the defaults.
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 a snapshot
editFinally, 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.