create tar from backup folders

pull/7/head
Florian Hartwich 2017-08-26 18:35:00 +02:00
parent 7e970940ae
commit c22256f2aa
1 changed files with 7 additions and 2 deletions

View File

@ -21,14 +21,19 @@ 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')/
DATE=$(date '+%Y-%m-%d')
mongoexport --db cc --collection $i --out ${DATE}/collections/${i}.json;
cp -R ../api/resource ${DATE}/
tar -zcf ${DATE}.tar.gz ${DATE}
rm -R ${DATE}
if [ $(ls -l | grep -c ^d) -gt 5 ]; then
deleteOldest
fi
else
tar -xzf ${1}.tar.gz
mongoimport --db cc --collection $i --drop --file ${1}/collections/${i}.json
rm -rf ../api/resource
cp -Rv ${1}/resource ../api/
rm -R ${1}
fi
done