Mercurial > public > ssdt-docker
view scripts/backup-document-store.sh @ 586:f897ce55c610 production v2.19.0
flow: Merged <release> '2.19.0' to <master> ('production').
author | Marc Davis <marc.davis@mcoecn.org> |
---|---|
date | Thu, 05 Sep 2024 14:09:51 -0400 |
parents | 52c2ec5ddeb5 |
children |
line wrap: on
line source
#!/bin/bash projectDir=${1:-$PWD} cd "$projectDir" || echo "Unable to change to project directory: $projectDir" function prop { grep "${1}" .env/ssdt-document-store-shared.properties|cut -d'=' -f2 } entityId=$(prop 'entityId' | tr -d '"') repository="${entityId}_fs_backup" certificate=${projectDir}/http_ca.crt baseUrl="https://$(prop 'DOCUMENTSTORE_ELASTIC_HOST' | tr -d '"'):$(prop 'DOCUMENTSTORE_ELASTIC_PORT' | tr -d '"')" elasticPassword=$(prop 'ELASTIC_PASSWORD' | tr -d '"') verifyRepository=$(curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X POST "${baseUrl}/_snapshot/${repository}/_verify?pretty") countMissingException=$(echo "${verifyRepository}" | grep -c "repository_missing_exception") if [ "$countMissingException" -gt 0 ]; then echo "creating Repository ${repository}" curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X PUT "${baseUrl}/_snapshot/${repository}?pretty" -H 'Content-Type: application/json' -d' { "type": "fs", "settings": { "location": "/usr/share/elasticsearch/backup", "compress": true } } ' fi snapshotName="%3C${entityId}-snapshot-%7Bnow%2Fs%7Byyyy.MM.dd-HH.mm.ss%7D%7D%3E" curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X PUT "${baseUrl}/_snapshot/${repository}/${snapshotName}?pretty"