opt-cc/backup/backup.sh

19 lines
522 B
Bash
Executable File

#!/bin/bash
# array of available collection names
col=(app_user awarding decoration rank squad user)
for i in "${col[@]}"
do
# provide date for restore process, if data import is needed
if [ -z "$1" ]
then
mongoexport --db cc --collection $i --out $(date '+%Y-%m-%d')/collections/${i}.json;
cp -R ../api/resource $(date '+%Y-%m-%d')/
else
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json
rm -rf ../api/resource
cp -Rv ${1}/resource ../api/
fi
done