top of page

Admin Tasks: â€‹

  • ​Create repository​​

Create repo. 

import os

import boto3

import requests

from requests_aws4auth import AWS4Auth

import requests

proxies={'http': None, 'https': None}

host = 'https://endpoint_name.com/'

region = 'us-east-1' # e.g. us-west-1

service = 'es'

credentials = boto3.Session().get_credentials()

awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)

# Register repository

path = '_snapshot/my_repository' # the OpenSearch API endpoint

url = host + path

payload = {

"type": "s3",

"settings": {

"bucket": "packages-name-us-east-1",

"region": "us-east-1",

"role_arn": "arn:aws:iam::xxxxxxx:role/user-role-us-east-1",

"base_path": "es_data/data",

"server_side_encryption" : "true"

    }

}

headers = {"Content-Type": "application/json"}

r = requests.put(url, auth=awsauth, proxies=proxies,json=payload, headers=headers)

print(r.status_code)

print(r.text)

​​

  • Working  Snapshot
     

    1. Create snapshot
               PUT /_snapshot/my_repository/my_snapshot

    2. Restore snapshot

               POST /_snapshot/my_repository/my_snapshot/_restore

    3. Restore specific index

      POST /_snapshot/my_repository/my_snapshot/_restore
      { "indices": "my_index",|
      "rename_pattern": "my_index",
      "rename_replacement": "my_index_new",
      "include_global_state": false
      }

​

 

 

 

 

 

 

 

 

 

 

 

 

 

 

​

bottom of page