forked from OpenBeta/openbeta-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed-db.sh
executable file
·28 lines (20 loc) · 877 Bytes
/
seed-db.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
# Rebuild your local database with a copy of OpenBeta staging database.
#
# To keep running time short, the script only downloads the remote
# database dump file once. Specify 'download' argument to force download.
#
# Syntax:
# ./seed-db.sh [download]
#
#!/bin/bash
FILE_NAME="openbeta-stg-db.tar.gz"
REMOTE_FILE="https://storage.googleapis.com/openbeta-dev-dbs/$FILE_NAME"
if [[ ! -f ${FILE_NAME} || ${1} == "download" ]]; then
echo "Downloading db file(s)..."
wget --content-disposition $REMOTE_FILE
fi
rm -rf ./db-dumps/staging/openbeta
tar xzf $FILE_NAME
. .env
connStr="${MONGO_SCHEME}://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@${MONGO_SERVICE}/${MONGO_DBNAME}?authSource=${MONGO_AUTHDB}&tls=${MONGO_TLS}&replicaSet=${MONGO_REPLICA_SET_NAME}"
mongorestore --uri "$connStr" -d=${MONGO_DBNAME} --gzip --drop ./db-dumps/staging/openbeta