Restoring snapshots by using _snapshot API
You can restore indices of OpenSearch data by using
_snapshot API.
About this task
_snapshot API is described on the Take and restore snapshots
Procedure
- Scale down the operator deployment.
- Retrieve the initial number of initial replicas.
kubectl get deployment ibm-bai-insights-engine-operator -o jsonpath='{.spec.replicas}' - Scale down the number of operator deployments to 0.
kubectl scale --replicas=0 deployment ibm-insights-engine-operator
- Retrieve the initial number of initial replicas.
- Stop the Flink event processors.
- Delete the Flink job submitters.
kubectl delete Job -l 'app.kubernetes.io/name in (ibm-business-automation-insights)' - Retrieve the management service URL and credentials.
For instructions, see Accessing Business Automation Insights services.
- Cancel the Flink jobs.
curl -X POST -k -u ${MANAGEMENT_USERNAME}:${MANAGEMENT_PASSWORD} "${MANAGEMENT_URL}/api/v1/processing/jobs/savepoints?cancel-Job=true"
- Delete the Flink job submitters.
- List the indices to restore.
OPENSEARCH_URL="https://$(kubectl get routes opensearch-route -o jsonpath="{.spec.host}" -n "$NAMESPACE")" OPENSEARCH_USERNAME=$(kubectl get secret/opensearch-admin-user -o json -n "$NAMESPACE" | jq -r '.data|keys[0]') OPENSEARCH_PASSWORD=$(kubectl extract secret/opensearch-admin-user --keys="$OPENSEARCH_USERNAME" --to=- -n "$NAMESPACE" 2>/dev/null) OPENSEARCH_INDEXES=$(curl -k -u ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD} -X GET "${OPENSEARCH_URL}/_cat/indices?h=index" | grep "icp4ba-bai") - Close each index in the list.
echo "$OPENSEARCH_INDEXES" | while read -r idx; do curl -k -u ${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD} -X POST "${OPENSEARCH_URL}/${idx}/_close" donefor idx in ${OPENSEARCH_INDEXES}; do curl -k -u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" -X POST "${OPENSEARCH_URL}/${idx}/_close" done - List all available repositories.
curl -k -u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" -H "Content-Type: application/json" -X GET "${OPENSEARCH_URL}/_snapshot/" - List all snapshots in the repository.
REPOSITORY_NAME=my_backup curl -k -u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" -H "Content-Type: application/json" -X GET "${OPENSEARCH_URL}/_snapshot/${REPOSITORY_NAME}/_all" | jq - Restore these indices by using the OpenSearch
_snapshotAPI.curl -k -u "${OPENSEARCH_USERNAME}:${OPENSEARCH_PASSWORD}" -H "Content-Type: application/json" -X POST "${OPENSEARCH_URL}/_snapshot/<your_repository_name>/<your_snapshot_name>/_restore" -d '{"indices": "icp4ba-bai*"}' - Scale the operator deployment back up to redeploy the Flink jobs.
kubectl scale --replicas=<initialReplicas> deployment ibm-insights-engine-operator