[ How to take elasticsearch backup (snapshots) on AWS S3 bucket ]
[ first create snapshot path using postman ]
PUT http://elastic.mylocal.com/_snapshot/s3_repository
{
"type": "s3",
"settings": {
"bucket": "mylocals3backup",
"base_path": "elasticsearch_backup/local_elasticsearch_backup",
"region": "ap-southeast-1",
"access_key": "XXXXXXXXXXXXXXXXXXXX",
"secret_key": "XXXXXXXXXXXXXXXXXXXX"
}
}'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ Create Elasticsearch Backup Script ]
# vim /root/scripts/elasticsearch_backup.sh
#!/bin/bash
_TODAY_DATE=snp-$(date +%F-%H%M-%S)
curl -XPUT "http://elastic.mylocal.com/_snapshot/s3_repository/$_TODAY_DATE?wait_for_completion=true" -d'
{
"indices": "index1,index2",
"ignore_unavailable": true,
"include_global_state": false
}' -H "Content-Type:application/json" > /tmp/elasticsearch_backup_result.txt
mailx -r "system@mylocal.com" -s "Elasticsearch Snapshot Backup" -S smtp="127.0.0.1:25" user1@mylocal.com,user2@mylocal.com<<EOF
Hi Team,
Live Elasticsearch Snapshot Backup has been successfully done.
Backup has been copied on s3 bucket.
BACKUP_PATH = s3://mylocals3backup/elasticsearch_backup/local_elasticsearch_backup
SNAPSHOT_NAME = $_TODAY_DATE
FULL_DISCRIPTION =
`cat /tmp/elasticsearch_backup_result.txt`
EOF
> /tmp/elasticsearch_backup_result.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ Set Cron ]
## [Elasticsearch Backup Script] ##
0 */1 * * * /bin/sh /root/scripts/elasticsearch_backup.sh
0 */1 * * * /bin/sh /root/scripts/elasticsearch_backup.sh
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No comments:
Post a Comment