Mongodb 定时备份脚本

脚本   mongodb  

1. mongodb 自动备份

#!/bin/bash
nowtime=date +"%Y-%m-%d_%H-%M-%S"

back_dir="/data/backup/db"  
mkdir -p $back_dir/$nowtime  
/usr/local/mongodb/bin/mongodump -h 127.0.0.1 -d DB -o ${back_dir}/${nowtime}

if [ $? -eq 0 ]  
then  
echo "back successfully!"  
else  
echo "back failure!"  
fi  

2. mongodb 更新脚本

#!/bin/bash
dbhost=$1  
dbname=$2  
file=$3  
mongo $dbhost/$dbname -ugamewrite -p9dcea698 $file