Pradeep,
I actually managed to get ahold of an S3 bucket to test this on and was successful in saving and restoring indices with Wazuh 4.3.10.
I did run into a few road bumps which I hope I can help you avoid.
Most of the procedure was taken from here:
So first thing you should create your S3 bucket and give your user/role the proper policy over it:
{
"Version": "2012-10-17",
"Statement": [{
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::your-bucket",
"arn:aws:s3:::your-bucket/*"
]
}]
}
Now, before you proceed, you are going to need to change line 81 of the /usr/share/wazuh-indexer/bin/opensearch-env script
from this:
if [ -z "$OPENSEARCH_PATH_CONF" ]; then OPENSEARCH_PATH_CONF="$OPENSEARCH_HOME"/config; fi
to this:
if [ -z "$OPENSEARCH_PATH_CONF" ]; then OPENSEARCH_PATH_CONF="/etc/wazuh-indexer/"; fi
With that done, you now need to install the proper opensearch plugin:
/usr/share/wazuh-indexer/bin/opensearch-plugin install repository-s3
Add the following lines to /etc/wazuh-indexer/opensearch.yml
s3.client.default.endpoint: s3.amazonaws.com
s3.client.default.max_retries: 3
s3.client.default.path_style_access: false
s3.client.default.protocol: https
s3.client.default.read_timeout: 50s
s3.client.default.use_throttle_retries: true
Now replace the access and secret keys in the following commands and run them.
export AWS_ACCESS_KEY_ID='YOUR_ACCESS_KEY'
export AWS_SECRET_ACCESS_KEY='YOUR_SECRET_KEY'
echo $AWS_ACCESS_KEY_ID | /usr/share/opensearch/bin/opensearch-keystore add --stdin s3.client.default.access_key
echo $AWS_SECRET_ACCESS_KEY | /usr/share/wazuh-indexer/bin/opensearch-keystore add --stdin s3.client.default.secret_key
chown wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/opensearch.keystore
systemctl restart wazuh-indexer
If everything went well, you should now be able to login to the Wazuh Dashboard, go to the Stack Icon, select "Dev Tools" and run the following commands to register the repository and take snapshots:
This will reload the credentials from the keystore:
POST _nodes/reload_secure_settings
With the following we are registering the S3 bucket as a snapshot repo:
PUT _snapshot/my-s3-repository
{
"type": "s3",
"settings": {
"bucket": "your_bucket_name",
"region": "your_bucket_region"
}
}
We can now start backing up data:
PUT _snapshot/my-s3-repository/1
{
"indices": "YOUR_INDICES_NAMES_HERE",
"ignore_unavailable": true,
"include_global_state": false,
"partial": false
}
You can check your snapshot data by running something like so:
GET _snapshot/my-s3-repository/_all
So far, you would have backed up your indexed data.
You can either remove the original index to test restoring it, our you can use a renaming pattern to test restoring without modifying current indices:
POST _snapshot/my-repository/2/_restore
{
"indices": "YOUR_INDICES_NAMES_HERE",
"ignore_unavailable": true,
"include_global_state": false,
"include_aliases": false,
"partial": false,
"rename_pattern": "(.+)",
"rename_replacement": "restored-$1",
"index_settings": {
"index.blocks.read_only": false
},
"ignore_index_settings": [
"index.refresh_interval"
]
}
This is pretty much the full circle.
Once again, this was mostly taken from here:
Save for the modification to the opensearch-env script.
Let me know if this worked.
Regards,
Federico