赞
踩
${sourcepath}mongodump --host 127.0.0.1:27017 -d dbName--out ${targetpath}/${nowtime}
***************************************************************************************************************************
#!/bin/bash
#backup MongoDB
#mongodump命令路径
sourcepath='/usr/bin/'
targetpath='/mnt/home/mbBack/mbBack_list'
deleteTime=$(date -d '-7 days' "+%Y%m%d")
if [ -d "${targetpath}/${deleteTime}/" ]
then
rm -rf "${targetpath}/${deleteTime}/"
echo "=======${targetpath}/${deleteTime}/===删除成功=="
fi
echo "===$deleteTime ==="
nowtime=$(date +%Y%m%d)
start()
{
${sourcepath}mongodump --host 127.0.0.1:27017 -d new_pangolin_management_db --out ${targetpath}/${nowtime}
}
execute()
{
start
if [ $? -eq 0 ]
then
echo "back successfully!"
else
echo "back failure!"
fi
}
if [ ! -d "${targetpath}/${nowtime}/" ]
then
mkdir ${targetpath}/${nowtime}
fi
execute
echo "============== back end ${nowtime} =============="
***************************************************************************************************************************
mongorestore -h 127.0.0.1:27017 -d dbName /usr/local/src/mbBack/mbBack_list/datetime/dbname
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。