From afc33a400265dbf8bc5c3e6c8489a402ddb7ebc3 Mon Sep 17 00:00:00 2001 From: Alexis Ben Miloud--Josselin Date: Fri, 9 Mar 2018 10:39:59 +0100 Subject: [PATCH] Update elasticsearch snapshot --- zzz_evobackup | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/zzz_evobackup b/zzz_evobackup index ab99514..5cbfc97 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -122,13 +122,20 @@ mkdir -p -m 700 /home/backup # cp /var/lib/redis/dump.rdb /home/backup/ ## ElasticSearch : example with rsync (warning: don't forget to use NFS if you have a cluster) +# DATE=$(date +%F) ## Disable ES translog flush # curl -s -XPUT 'localhost:9200/_settings' -d '{"index.translog.disable_flush": true}' >/dev/null -## Flushes translog -# curl -s 'localhost:9200/_flush' | grep -qe '"ok":true' -## If it succeed, do an rsync of the datadir +## Flushes translog and check if snapshot has not already been made today +# curl -s 'localhost:9200/_flush' | grep -qe '"ok":true' && +# curl -s -XDELETE "localhost:9200/_snapshot/snaprepo/snapshot_${DATE}" | grep -qv 404 +## If it succeed, do a snapshot and remove old ones # if [ $? -eq 0 ]; then -# rsync -a /var/lib/elasticsearch /home/backup/ +# curl -s -XPUT "localhost:9200/_snapshot/snaprepo/snapshot_${DATE}?wait_for_completion=true" -o /tmp/es_snapshot_${DATE}.log +# cd /home/backup-elasticsearch/snaprepo +# for i in $(curl -s -XGET "localhost:9200/_snapshot/snaprepo/_all?pretty=true" | grep '^ *"snapshot" : "snapshot_.*",$' | cut -d_ -f2 | sed 's/",$//' | head -n-10); do +# curl -s -XDELETE "localhost:9200/_snapshot/snaprepo/snapshot_${i}" +# done +# cd - # else # echo "Error when flushing ES translog indexes." # fi