Restoring Elasticsearch Backup
Restoring data from backup snapshots involves a series of steps to ensure that the indices are properly closed before the restore operation and reopened afterward. Additionally, clearing internal caches and restarting the webMethods API Gateway server is recommended to ensure the restored data is fully integrated.
To restore Elasticsearch
- Ensure your Elasticsearch cluster is up and running.
-
Close the indices to be restored.
A sample command to close all the indices is as follows:
curl -si -X POST "http://es-host:es-port/gateway_tenant_name_*/_close"
In this example, the Elasticsearch cluster is assumed to be running on es-host with port es-port.
-
Restore the indices from the snapshot using the Elasticsearch API.
POST _snapshot/repo-name/backup-name_restore?wait_for_completion={true/false} { "indices": "gateway_tenant_*" }
In the Elasticsearch API:
- Replace
repo-name
with the name of the backup repository. - Replace
backup-name
with the name of the snapshot to restore. wait_for_completion
is a query parameter indicating whether the request must wait for the restore operation to complete before responding. It can be set to eithertrue
orfalse
. The default value isfalse
.indices
specifies the indices you want to restore. In this example, it includes indices matching the patterngateway_tenant_*
. Replace tenant with the appropriate tenant name.
A sample command to restore Elasticsearch with default tenant is as follows:curl -si -X POST -H "content-type:application/json" -d '{"indices": "gateway_default_*"}' http://es-host:es-port/_snapshot/myrepo/api_data_store_backup/_restore?wait_for_completion=true
In this example:
- The Elasticsearch cluster is assumed to be running on es-host with port es-port.
- The backup repository name is
myrepo
. - The snapshot
api_data_store_backup
is restored for indices matching the patterngateway_default_*
. - The request immediately returns a response, while the restore operation runs in the background.
- Replace
-
Reopen the indices after the restore operation is complete.
A sample command to open the indices is as follows:
curl -si -X POST "http://es-host:es-port/gateway_tenant_name_*/_open"
In this example, the Elasticsearch cluster is assumed to be running on es-host with port es-port.
-
Verify the status of the restore operation.
If you have triggered a restore operation with
wait_for_completion=true
, you can determine the current status of the restore operation using the following command:GET _snapshot/
repo-name
/backup-name
/_statusIn this command, replace
repo-name
andbackup-name
with your repository and backup names, respectively.The JSON response from the Elasticsearch provides detailed information about the status of the restore operation.
- Restart the webMethods API Gateway server to clear all internal caches and ensure the restored data is fully integrated.