Snapshot Lifecycle Management (SLM) in Python 3

Hello,

I had done "snapshot" for the indexes in an database Elasticsearch by script :

es.snapshot.create(repository=repository_name, snapshot=snapshot_name)

I would like to Automatic backup with SML. I really need your help of my frend here to show me the step how to create an SML policy, and how to use, how to write the code. I have refered this link, but do not clear how to do (https://www.elastic.co/.../getting-started-snapshot...)

I think I misunderstood how is "policy_id" or there is the steps that I do not know before running the below code - The code I wrote to Automatic backup with SML:
#################
policy_id= "container2" #(Required, string) ID for the snapshot lifecycle policy you want to create or update.

request_body = { #(Required, object) Configuration for each snapshot created by the policy.

"schedule": "0 30 1 * * ?", # When the snapshot should be taken, in this case, 1:30am daily

"name": "<container2-{now/d}>", # The name each snapshot should be given

"repository": "Repo1", # Which repository to take the snapshot in

"config": { # Any extra snapshot configuration

"indices": ["container2"],  #Data streams and indices the snapshot should contain  (container2,container3)

"ignore_unavailable": False, 

"include_global_state": False #

},

"retention": { #Optional retention configuration

"expire_after": "30d", #    Keep snapshots for 30 days

"min_count": 5,  # Always keep at least 5 successful snapshots, even if they’re more than 30 days old

"max_count": 50  #  Keep no more than 50 successful snapshots, even if they’re less than 30 days old ( <200)

}
}

es.slm.put_lifecycle(policy_id = policy_id, body = request_body)

#############
The error I obtained is in the picture

Thanks very much in advance for your help

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