-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport-songs-db.sh
18 lines (13 loc) · 967 Bytes
/
import-songs-db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
echo "----------------------------------------------------------------------------------------------------"
echo "****************************************************************************************************"
echo "----------------------------------------------------------------------------------------------------"
echo "-----BEGIN IMPORTING TEST DATA-----"
[ -d "song_db_backup" ] || mkdir "song_db_backup"
echo "-----Backing up existing DB-----"
mongodump -d -test -o ./"song_db_backup"/`date +%Y-%m-%d_%H-%M-%S` || (echo "[ERROR] Could not create DB backup" && exit 1)
echo "-----Deleting existing DB-----"
mongo -test --eval "db.dropDatabase()" || (echo "[ERROR] Could not delete DB" && exit 1)
echo "-----Importing test data from ./MOCK_DATA to DB-----"
mongoimport --db -test --jsonArray --collection songs --file "./MOCK_DATA.json" || (echo "[ERROR] Could not import test data" && exit 1)
echo "-----END IMPORTING TEST DATA-----"