From eb85dc6175d8b063af7c968b6d02e8f85fb9ffdb Mon Sep 17 00:00:00 2001 From: Alexis Ben Miloud--Josselin Date: Wed, 21 Nov 2018 14:32:38 +0100 Subject: [PATCH] Add clusterized elasticsearch snapshots --- zzz_evobackup | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zzz_evobackup b/zzz_evobackup index 4a0114d..6ac5a75 100755 --- a/zzz_evobackup +++ b/zzz_evobackup @@ -128,6 +128,21 @@ mkdir -p -m 700 /home/backup ## See: https://wiki.evolix.org/HowtoElasticsearch#snapshots-et-sauvegardes # curl -s -XDELETE "localhost:9200/_snapshot/snaprepo/snapshot.daily" -o /tmp/es_delete_snapshot.daily.log # curl -s -XPUT "localhost:9200/_snapshot/snaprepo/snapshot.daily?wait_for_completion=true" -o /tmp/es_snapshot.daily.log +## Clustered version here +## It basically the same thing except that you need to check that NFS is mounted +# if ss | grep ':nfs' | grep -q 'ip\.add\.res\.s1' && ss | grep ':nfs' | grep -q 'ip\.add\.res\.s2' +# then +# curl -s -XDELETE "localhost:9200/_snapshot/snaprepo/snapshot.daily" -o /tmp/es_delete_snapshot.daily.log +# curl -s -XPUT "localhost:9200/_snapshot/snaprepo/snapshot.daily?wait_for_completion=true" -o /tmp/es_snapshot.daily.log +# else +# echo 'Cannot make a snapshot of elasticsearch, at least one node is not mounting the repository.' +# fi +## If you need to keep older snapshot, for example the last 10 daily snapshots, replace the XDELETE and XPUT lines by : +# for snapshot in $(curl -s -XGET "localhost:9200/_snapshot/snaprepo/_all?pretty=true" | grep -Eo 'snapshot_[0-9]{4}-[0-9]{2}-[0-9]{2}' | head -n -10); do +# curl -s -XDELETE "localhost:9200/_snapshot/snaprepo/${snapshot}" | grep -v -Fx '{"acknowledged":true}' +# done +# date=$(date +%F) +# curl -s -XPUT "localhost:9200/_snapshot/snaprepo/snapshot_${date}?wait_for_completion=true" -o /tmp/es_snapshot_${date}.log ## RabbitMQ : export config #rabbitmqadmin export /home/backup/rabbitmq.config >> /var/log/evobackup.log