Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- path=/opt/elasticsearch/data/elasticsearch/nodes
- backup=/backup/es_2.1.1/nodes
- index=($(ls -rt $path/0/indices))
- # echo ${#index[@]}, array length
- if [ ${#index[@]} -le 31 ]; then
- logger -p local3.info disk has enough space, no need to rotate -f /backup/rotate-es/rotate-es.log
- exit
- fi
- index=${index[0]}
- echo $index
- cp -R $path/0/indices/$index $backup/0/indices/
- logger -p local3.info $index coppied to /nodes/0/ -f /backup/rotate-es/rotate-es.log
- if [ -d "$path/1/indices/$index" ]; then
- cp -R $path/1/indices/$index $backup/1/indices/
- logger -p local3.info $index coppied to /nodes/1/ -f /backup/rotate-es/rotate-es.log
- fi
- if [ -d "$path/2/indices/$index" ]; then
- cp -R $path/2/indices/$index $backup/2/indices
- logger -p local3.info $index coppied to /nodes/2/ -f /backup/rotate-es/rotate-es.log
- fi
- # 'localhost:9200/'"$index"'/?pretty'
- curl -XDELETE 'localhost:9200/'"$index"'/?pretty'
Advertisement
Add Comment
Please, Sign In to add comment