Backing up ElasticSearch's configuration ONLY

Hi,

From the docs I can see how to backup the indices.
However that could take a hefty amount of time.
Is there a way to backup just the configuration itself i.e templates, alerts, mappings etc?

thanks
gil

Hello Gil,

Yes - you can do this using snapshot/restore and the include_global_state parameter - here's an example to illustrate.

# Repository to store cluster state in
PUT /_snapshot/my_backup
{
  "type": "fs",
  "settings": {
        "location": "/path/to/repo"
  }
}

# Put a template, and confirm it exists
PUT _template/test
{
  "template": "test-*",
  "settings": {
    "number_of_shards": 1
  }
}
GET /_template/test

# Create a snapshot including cluster state
# DELETE _snapshot/my_backup/snapshot_1
PUT /_snapshot/my_backup/snapshot_1
{
  "indices": "not_an_index_which_exists",
  "ignore_unavailable": true,
  "include_global_state": true
}
GET /_snapshot/my_backup/snapshot_1

# Delete template and ensure it is gone
DELETE _template/test
GET /_template/test

# Restore the snapshot
POST /_snapshot/my_backup/snapshot_1/_restore
{
  "include_global_state":true
}

# Confirm template has been recreated
GET /_template/test

You can find further documentation here including:

If cluster state is restored with include_global_state (defaults to false), the restored templates that don’t currently exist in the cluster are added and existing templates with the same name are replaced by the restored templates. The restored persistent settings are added to the existing persistent settings.

Hi

I just tested this out.
It does not seem like it backs up Watchers.
Is there a solution to that?

Thanks
Gil

Hello Gil,

For watches you will have to include the .watches index.

Cheers,
-Robin-

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.