Tutorial: Snapshot and Restore

edit

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

edit

This example shows you how to register a shared file system repository and store snapshots.

Before you begin, you must first mount the file system to the same location on all master and data nodes. Then add the file system’s path or parent directory to the path.repo setting in elasticsearch.yml for each master and data node.

Register a repository

edit

Use Snapshot and Restore to register the repository where your snapshots will live.

  1. Open the main menu, then click Stack Management > Snapshot and Restore.
  2. Click Register a repository in either the introductory message or Repository view.
  3. Enter a name for your repository, for example, my_backup.
  4. Select Shared file system.

    Register repository

  5. Click Next.
  6. In File system location, enter the path to the snapshot repository, /tmp/es-backups.
  7. In Chunk size, enter 100mb so that snapshot files are not bigger than that size.
  8. 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

edit

Use the snapshot API to create a snapshot.

  1. Open the main menu, click Dev Tools, then select Console.
  2. Create the snapshot:

    PUT /_snapshot/my_backup/2099-04-25_snapshot?wait_for_completion=true

    In this example, the snapshot name is 2099-04-25_snapshot. You can also use date math expression for the snapshot name.

  3. Return to Snapshot and Restore.

    Your new snapshot is available in the Snapshots view.

Create a snapshot lifecycle policy

edit

Now you’ll automate the creation and deletion of snapshots using the repository created in the previous example.

  1. Open the Policies view.
  2. Click Create a policy.

    Create policy wizard

  3. As you walk through the wizard, enter the following values:

    Logistics

    Policy name

    daily-snapshots

    Snapshot name

    <daily-snap-{now/d}>

    Repository

    my_backup

    Schedule

    Every day at 1:30 a.m.

    Snapshot settings

    Data streams and indices

    Select the data streams and indices to back up. By default, all data streams and 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

  4. 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

edit

Finally, you’ll restore data streams and indices from an existing snapshot.

  1. In the Snapshots view, find the snapshot you want to restore, for example 2099-04-25_snapshot.
  2. Click the restore icon in the Actions column.
  3. As you walk through the wizard, enter the following values:

    Logistics

    Data streams and indices

    Toggle to choose specific data streams and indices to restore. Use the default to restore all data streams and indices in the snapshot.

    Rename data streams and indices

    Toggle to give your restored data streams and indices new names. Use the default to restore the original data stream and 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.

  4. 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 data streams and indices.