finish backup-script for export/import data
parent
2570a82cfa
commit
a215d41ec3
|
@ -44,14 +44,13 @@ Thumbs.db
|
||||||
/public
|
/public
|
||||||
|
|
||||||
resource/
|
resource/
|
||||||
|
mongodb-data/
|
||||||
backup/collections/
|
backup/
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
node_modules
|
node_modules
|
||||||
*/nbproject*
|
*/nbproject*
|
||||||
.npm/
|
.npm/
|
||||||
mongodb-data/
|
|
||||||
.bash_history
|
.bash_history
|
||||||
.bash_logout
|
.bash_logout
|
||||||
.bashrc
|
.bashrc
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# array of available collection names
|
||||||
col=(app_user awarding decoration rank squad user)
|
col=(app_user awarding decoration rank squad user)
|
||||||
|
|
||||||
for i in "${col[@]}"
|
for i in "${col[@]}"
|
||||||
do
|
do
|
||||||
if [ "$1" == "restore" ]
|
# provide date for restore process, if data import is needed
|
||||||
|
if [ -z "$1" ]
|
||||||
then
|
then
|
||||||
mongoimport --db cc --collection $i --file collections/${i}.json
|
mongoexport --db cc --collection $i --out $(date '+%Y-%m-%d')/collections/${i}.json;
|
||||||
|
cp -R ../api/resource $(date '+%Y-%m-%d')/
|
||||||
else
|
else
|
||||||
mongoexport --db cc --collection $i --out collections/${i}.json;
|
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json
|
||||||
|
rm -rf ../api/resource
|
||||||
|
cp -Rv ${1}/resource ../api/
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue