ebruakagunduz

rotate-es.sh

Jun 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. path=/opt/elasticsearch/data/elasticsearch/nodes
  4.  
  5. backup=/backup/es_2.1.1/nodes
  6. index=($(ls -rt $path/0/indices))
  7.  
  8. # echo ${#index[@]}, array length
  9. if [ ${#index[@]} -le 31 ]; then
  10. logger -p local3.info disk has enough space, no need to rotate -f /backup/rotate-es/rotate-es.log
  11. exit
  12. fi
  13.  
  14. index=${index[0]}
  15. echo $index
  16.  
  17. cp -R $path/0/indices/$index $backup/0/indices/
  18. logger -p local3.info $index coppied to /nodes/0/ -f /backup/rotate-es/rotate-es.log
  19.  
  20. if [ -d "$path/1/indices/$index" ]; then
  21. cp -R $path/1/indices/$index $backup/1/indices/
  22. logger -p local3.info $index coppied to /nodes/1/ -f /backup/rotate-es/rotate-es.log
  23. fi
  24.  
  25. if [ -d "$path/2/indices/$index" ]; then
  26. cp -R $path/2/indices/$index $backup/2/indices
  27. logger -p local3.info $index coppied to /nodes/2/ -f /backup/rotate-es/rotate-es.log
  28. fi
  29.  
  30. # 'localhost:9200/'"$index"'/?pretty'
  31.  
  32. curl -XDELETE 'localhost:9200/'"$index"'/?pretty'
Advertisement
Add Comment
Please, Sign In to add comment