opt-cc/api/apib/mongo-test-data/tets-data-extract.sh

21 lines
584 B
Bash
Executable File

#!/usr/bin/env bash
# execute script in its location folder
cd $(dirname $0)
DB_NAME="cc-test"
# array of available collection names
col=(app_user awarding campaign decoration logBudget logFlag logKill logPoints logRespawn logRevive logTransport logVehicle player promotion rank squad user war)
for i in "${col[@]}"
do
if [ "$1" == "import" ]
then
mongoimport --quiet --db ${DB_NAME} --collection $i --drop --file ${i}.json
else
echo -e "$(date "+%Y-%m-%dT%T.%3N%z")\tTable: ${i}"
mongoexport --db ${DB_NAME} --collection $i --out ${i}.json;
fi
done