标签:dir mongodb tmp amp tab run use doc store
rm -rf /tmp/mongodump && mkdir /tmp/mongodump
docker run -it --rm --link lps-mongodb:mongo -v /tmp/mongodump:/tmp mongo bash -c ‘mongodump -h mongo -d menusifu -p 27017 -o /tmp‘
tar -zcvf aa1.tar.gz -C /tmp/mongodump *
tar -zcvf aa.tar.gz /tmp/mongodump/menusifu
rm -rf /tmp/mongodump
docker run -it --link lps-mongodb:mongo --rm mongo bash -c ‘mongo mongo:27017/menusifu‘
rm -rf /tmp/mongodump && mkdir /tmp/mongodump
docker run -it --rm --link mongo:mongo -v /tmp/mongodump:/tmp mongo bash -c ‘mongodump -v --host $MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT --db ‘$1‘ --out=/tmp‘
tar -cvf $2 -C /tmp/mongodump *
rm -rf /tmp/mongodump
./mongo-backup.sh [database_name] ~/backup.tar
TMP_DIR="/tmp/mongorestore/"
rm -rf $TMP_DIR && mkdir $TMP_DIR
if [[ $1 =~ \.tar$ ]];
then
#FILENAME=$(echo $1 | sed ‘s/.*\///‘)
FILENAME=$2"/"
mkdir $TMP_DIR
echo "Data will be extracted into :"$TMP_DIR
tar -C $TMP_DIR -xvf $1
else
FILENAME=$(echo $1 | sed ‘s/.*\///‘)
cp $1 $TMP_DIR$FILENAME
fi
docker run -it --rm --link mongo:mongo -v $TMP_DIR:/tmp mongo bash -c ‘mongorestore --drop -v --host $MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT --db ‘$2‘ /tmp/‘$FILENAME
rm -rf $TMP_DIR
./mongo-restore.sh ~/backup.tar [database_name]
./mongo-restore.sh ~/users.json [database_name]
docker mongo backup 不用找啦,就在这里。
标签:dir mongodb tmp amp tab run use doc store
原文地址:http://www.cnblogs.com/jayruan/p/6602693.html