2017-05-27 23:35:31 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-05-28 00:51:23 +02:00
|
|
|
# array of available collection names
|
2017-07-08 22:53:06 +02:00
|
|
|
col=(app_user awarding decoration rank squad user promotion player war)
|
2017-05-27 23:35:31 +02:00
|
|
|
|
|
|
|
for i in "${col[@]}"
|
|
|
|
do
|
2017-05-28 00:51:23 +02:00
|
|
|
# provide date for restore process, if data import is needed
|
|
|
|
if [ -z "$1" ]
|
2017-05-27 23:35:31 +02:00
|
|
|
then
|
2017-05-28 00:51:23 +02:00
|
|
|
mongoexport --db cc --collection $i --out $(date '+%Y-%m-%d')/collections/${i}.json;
|
|
|
|
cp -R ../api/resource $(date '+%Y-%m-%d')/
|
2017-05-27 23:35:31 +02:00
|
|
|
else
|
2017-05-28 00:51:23 +02:00
|
|
|
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json
|
|
|
|
rm -rf ../api/resource
|
|
|
|
cp -Rv ${1}/resource ../api/
|
2017-05-27 23:35:31 +02:00
|
|
|
fi
|
|
|
|
done
|