Mercurial > public > ssdt-docker
annotate scripts/restore-document-store.sh @ 424:52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
author | Robin Fronk <robin.fronk@mcoecn.org> |
---|---|
date | Tue, 19 Sep 2023 11:36:03 -0400 |
parents | |
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 snapshot=${2?Must provide snapshot name to restore} |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
5 |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
6 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
|
7 |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
8 function prop { |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
9 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
|
10 } |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
11 |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 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
|
16 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
|
17 |
52c2ec5ddeb5
DS-54: add backup, restore, and list snapshots scripts for document store
Robin Fronk <robin.fronk@mcoecn.org>
parents:
diff
changeset
|
18 curl --cacert "${certificate}" -s -u elastic:"${elasticPassword}" -X POST "${baseUrl}/_snapshot/${repository}/${snapshot}/_restore?pretty" |