#! /bin/bash
dataDb=$1
PATH=/usr/local/bin:$PATH
mongodump -d $dataDb -o /tmp
date=$(date +"%Y%m%d-%H%M%S$dataDb")
tar -zcvf /usr/share/app/mongo/$date.tar.gz /tmp/$dataDb
rm -rf /tmp/$dataDb
echo "done!"

#docker exec -it mongo /usr/share/app/ssh/backup.sh dbName

 

 

#! /bin/bash
tar=$1
originDb=$2
restoreDb=$3

PATH=/usr/local/bin:$PATH
mongo $2 --eval "printjson(db.dropDatabase())"
tar -xvf /usr/share/app/mongo/$tar -C /usr/share/app/mongo/
mongorestore -d $restoreDb /usr/share/app/mongo/tmp/$originDb
echo "done!"

 

 

#! /bin/bash
PATH=/usr/local/bin:$PATH
redis-cli SAVE
date=$(date +"%Y%m%d")
tar -zcvf /usr/share/app/redis/$date.tar.gz /data/
rm -rf /data/*
echo "done!"

 posted on 2017-04-08 10:04  jayruan  阅读(323)  评论(0编辑  收藏  举报