annotate scripts/backup-document-store.sh @ 555:eae4a6205738

remove onbuild
author belknapSSDT <zach.belknap@mcoecn.org>
date Thu, 23 May 2024 12:11:06 -0400
parents 52c2ec5ddeb5
children
rev   line source
424
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
1 #!/bin/bash
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
2
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
3 projectDir=${1:-$PWD}
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
4
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
5 cd "$projectDir" || echo "Unable to change to project directory: $projectDir"
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
6
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
7 function prop {
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
8 grep "${1}" .env/ssdt-document-store-shared.properties|cut -d'=' -f2
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
9 }
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
10
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
11 entityId=$(prop 'entityId' | tr -d '"')
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
12 repository="${entityId}_fs_backup"
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
13 certificate=${projectDir}/http_ca.crt
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
14 baseUrl="https://$(prop 'DOCUMENTSTORE_ELASTIC_HOST' | tr -d '"'):$(prop 'DOCUMENTSTORE_ELASTIC_PORT' | tr -d '"')"
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
15 elasticPassword=$(prop 'ELASTIC_PASSWORD' | tr -d '"')
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
16
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
17 verifyRepository=$(curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X POST "${baseUrl}/_snapshot/${repository}/_verify?pretty")
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
18
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
19 countMissingException=$(echo "${verifyRepository}" | grep -c "repository_missing_exception")
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
20
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
21 if [ "$countMissingException" -gt 0 ]; then
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
22 echo "creating Repository ${repository}"
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
23 curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X PUT "${baseUrl}/_snapshot/${repository}?pretty" -H 'Content-Type: application/json' -d'
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
24 {
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
25 "type": "fs",
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
26 "settings": {
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
27 "location": "/usr/share/elasticsearch/backup",
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
28 "compress": true
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
29 }
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
30 }
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
31 '
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
32 fi
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
33
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
34 snapshotName="%3C${entityId}-snapshot-%7Bnow%2Fs%7Byyyy.MM.dd-HH.mm.ss%7D%7D%3E"
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
35
52c2ec5ddeb5 DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff changeset
36 curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X PUT "${baseUrl}/_snapshot/${repository}/${snapshotName}?pretty"