-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup-metadata.sh
executable file
·54 lines (47 loc) · 2.07 KB
/
backup-metadata.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# OpenCRVS is also distributed under the terms of the Civil Registration
# & Healthcare Disclaimer located at http://opencrvs.org/license.
#
# Copyright (C) The OpenCRVS Authors. OpenCRVS and the OpenCRVS
# graphic logo are (registered/a) trademark(s) of Plan International.
set -e
DIR=$(cd "$(dirname "$0")"; pwd)
echo "Working dir: $DIR"
if [ "$REPLICAS" = "0" ]; then
HOST=mongo1
NETWORK=opencrvs_default
echo "Working with no replicas"
elif [ "$REPLICAS" = "1" ]; then
HOST=rs0/mongo1
NETWORK=opencrvs_overlay_net
echo "Working with 1 replica"
elif [ "$REPLICAS" = "3" ]; then
HOST=rs0/mongo1,mongo2,mongo3
NETWORK=opencrvs_overlay_net
echo "Working with 3 replicas"
elif [ "$REPLICAS" = "5" ]; then
HOST=rs0/mongo1,mongo2,mongo3,mongo4,mongo5
NETWORK=opencrvs_overlay_net
echo "Working with 5 replicas"
else
echo "Script must be passed an understandable number of replicas: 0,1,3 or 5"
exit 1
fi
mongo_credentials() {
if [ ! -z ${MONGODB_ADMIN_USER+x} ] || [ ! -z ${MONGODB_ADMIN_PASSWORD+x} ]; then
echo "--username $MONGODB_ADMIN_USER --password $MONGODB_ADMIN_PASSWORD --authenticationDatabase admin";
else
echo "";
fi
}
docker run --rm -v $DIR/backups:/backups --network=$NETWORK mongo:4.4 bash \
-c "mongodump $(mongo_credentials) --host $HOST -d hearth-dev --gzip --archive=/backups/hearth-dev.gz"
docker run --rm -v $DIR/backups:/backups --network=$NETWORK mongo:4.4 bash \
-c "mongodump $(mongo_credentials) --host $HOST -d openhim-dev --gzip --archive=/backups/openhim-dev.gz"
docker run --rm -v $DIR/backups:/backups --network=$NETWORK mongo:4.4 bash \
-c "mongodump $(mongo_credentials) --host $HOST -d user-mgnt --gzip --archive=/backups/user-mgnt.gz"
docker run --rm -v $DIR/backups:/backups --network=$NETWORK mongo:4.4 bash \
-c "mongodump $(mongo_credentials) --host $HOST -d application-config --gzip --archive=/backups/application-config.gz"