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
.
Body
-
Configuration for each snapshot created by the policy.
-
Name automatically assigned to each snapshot created by the policy. Date math is supported. To prevent conflicting snapshot names, a UUID is automatically appended to each snapshot name.
-
Repository used to store snapshots created by this policy. This repository must exist prior to the policy’s creation. You can create a repository using the snapshot repository API.
-
Retention rules used to retain and delete snapshots created by the policy.
-
Periodic or absolute schedule at which the policy creates snapshots. SLM applies schedule changes immediately.
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"
client.slm().putLifecycle(p -> p
.config(c -> c
.ignoreUnavailable(false)
.indices(List.of("data-*","important"))
.includeGlobalState(false)
)
.name("<daily-snap-{now/d}>")
.policyId("daily-snapshots")
.repository("my_repository")
.retention(r -> r
.expireAfter(e -> e
.time("30d")
)
.maxCount(50)
.minCount(5)
)
.schedule("0 30 1 * * ?")
);
{
"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
}
}
{
"schedule": "1h",
"name": "<hourly-snap-{now/d}>",
"repository": "my_repository",
"config": {
"indices": ["data-*", "important"]
}
}