码迷,mamicode.com
首页 > 数据库 > 详细

mongodb备份还原脚本

时间:2015-09-15 17:55:28      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

同步
echo off

set time_dir=%date:~0,4%-%date:~5,2%-%date:~8,2%

set bak_dir=mongo_na_world_svn2win_%time_dir%

set mongo_dir=E:\MongoDb\mongodb-win32-i386-2.2.3

set fromdb=db_eragon_game_na_world

%mongo_dir%\bin\mongodump.exe -h 192.168.102.237 -d %fromdb% -o %bak_dir%

mkdir tmp_dir


    xcopy %bak_dir%\%fromdb%\cf_* tmp_dir

    %mongo_dir%\bin\mongorestore.exe -h 192.168.102.237 -d db_eragon_game_na_world_w0 --drop --directoryperdb tmp_dir

    %mongo_dir%\bin\mongorestore.exe -h 192.168.102.237 -d db_eragon_game_na_world_w1 --drop --directoryperdb tmp_dir
   
    
    
    rd /s/q tmp_dir

rd /s/q %bak_dir%

pause

备份

echo off

set time_dir=%date:~0,4%-%date:~5,2%-%date:~8,2%

set bak_dir=temp_mongo_na_world_win2dev_%time_dir%

set mongo_dir=E:\MongoDb\mongodb-win32-i386-2.2.3

set fromdb=db_eragon_game_na_world_w0

%mongo_dir%\bin\mongodump.exe -h 192.168.102.237 -d %fromdb% -o %bak_dir%

mkdir mongo_na_world_win2dev_dir_%time_dir%

xcopy %bak_dir%\%fromdb%\cf_* mongo_na_world_win2dev_dir_%time_dir%

rd /s/q %bak_dir%

pause

mongodb备份还原脚本

标签:

原文地址:http://www.cnblogs.com/djzny/p/4810627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!