Query parameters
-
The period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to
-1
.Values are
-1
or0
. -
The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to
-1
.Values are
-1
or0
.
PUT
/_slm/policy/{policy_id}
Console
PUT /_slm/policy/daily-snapshots
{
"schedule": "0 30 1 * * ?",
"name": "<daily-snap-{now/d}>",
"repository": "my_repository",
"config": {
"indices": ["data-*", "important"],
"ignore_unavailable": false,
"include_global_state": false
},
"retention": {
"expire_after": "30d",
"min_count": 5,
"max_count": 50
}
}
resp = client.slm.put_lifecycle(
policy_id="daily-snapshots",
schedule="0 30 1 * * ?",
name="<daily-snap-{now/d}>",
repository="my_repository",
config={
"indices": [
"data-*",
"important"
],
"ignore_unavailable": False,
"include_global_state": False
},
retention={
"expire_after": "30d",
"min_count": 5,
"max_count": 50
},
)
const response = await client.slm.putLifecycle({
policy_id: "daily-snapshots",
schedule: "0 30 1 * * ?",
name: "<daily-snap-{now/d}>",
repository: "my_repository",
config: {
indices: ["data-*", "important"],
ignore_unavailable: false,
include_global_state: false,
},
retention: {
expire_after: "30d",
min_count: 5,
max_count: 50,
},
});
response = client.slm.put_lifecycle(
policy_id: "daily-snapshots",
body: {
"schedule": "0 30 1 * * ?",
"name": "<daily-snap-{now/d}>",
"repository": "my_repository",
"config": {
"indices": [
"data-*",
"important"
],
"ignore_unavailable": false,
"include_global_state": false
},
"retention": {
"expire_after": "30d",
"min_count": 5,
"max_count": 50
}
}
)
$resp = $client->slm()->putLifecycle([
"policy_id" => "daily-snapshots",
"body" => [
"schedule" => "0 30 1 * * ?",
"name" => "<daily-snap-{now/d}>",
"repository" => "my_repository",
"config" => [
"indices" => array(
"data-*",
"important",
),
"ignore_unavailable" => false,
"include_global_state" => false,
],
"retention" => [
"expire_after" => "30d",
"min_count" => 5,
"max_count" => 50,
],
],
]);
curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"schedule":"0 30 1 * * ?","name":"<daily-snap-{now/d}>","repository":"my_repository","config":{"indices":["data-*","important"],"ignore_unavailable":false,"include_global_state":false},"retention":{"expire_after":"30d","min_count":5,"max_count":50}}' "$ELASTICSEARCH_URL/_slm/policy/daily-snapshots"
Request examples
Create a policy
Run `PUT /_slm/policy/daily-snapshots` to create a lifecycle policy. The `schedule` is when the snapshot should be taken, in this case, 1:30am daily. The `retention` details specify to: keep snapshots for 30 days; always keep at least 5 successful snapshots, even if they're more than 30 days old; keep no more than 50 successful snapshots, even if they're less than 30 days old.
{
"schedule": "0 30 1 * * ?",
"name": "<daily-snap-{now/d}>",
"repository": "my_repository",
"config": {
"indices": ["data-*", "important"],
"ignore_unavailable": false,
"include_global_state": false
},
"retention": {
"expire_after": "30d",
"min_count": 5,
"max_count": 50
}
}
Run `PUT /_slm/policy/hourly-snapshots` to create a lifecycle policy that uses interval scheduling. It creates a snapshot once every hour. The first snapshot will be created one hour after the policy is modified, with subsequent snapshots every hour afterward.
{
"schedule": "1h",
"name": "<hourly-snap-{now/d}>",
"repository": "my_repository",
"config": {
"indices": ["data-*", "important"]
}
}