update old backup delete

feature/user-self-management
Florian Hartwich 2017-09-05 15:48:15 +02:00
parent 8531ced759
commit e346527df7
1 changed files with 4 additions and 13 deletions

View File

@ -3,16 +3,6 @@
# execute script in its location folder # execute script in its location folder
cd $(dirname $0) cd $(dirname $0)
deleteOldest() {
line_num=0
while IFS= read -r -d $'\0'; do
if [ $line_num == 1 ]; then
$(rm -rf ${REPLY})
fi
((line_num++))
done < <(find -maxdepth 1 -type d -print0 | sort -z)
}
# array of available collection names # array of available collection names
col=(app_user awarding decoration rank squad user promotion player war campaign) col=(app_user awarding decoration rank squad user promotion player war campaign)
@ -35,14 +25,15 @@ do
if [ -z "$1" ] if [ -z "$1" ]
then then
mongoexport --db cc --collection $i --out ${DATE}/collections/${i}.json; mongoexport --db cc --collection $i --out ${DATE}/collections/${i}.json;
if [ $(ls -l | grep -c ^d) -gt 5 ]; then
deleteOldest
fi
else else
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json
fi fi
done done
if [ $(ls -lt --hide=backup.sh | wc -l) -gt 6 ]; then
$(rm "$(ls -t --hide=backup.sh | tail -1)")
fi
if [ -z "$1" ] if [ -z "$1" ]
then then
tar -zcf ${DATE}.tar.gz ${DATE} tar -zcf ${DATE}.tar.gz ${DATE}