@echo off
@title MongoDB备份脚本
@color 2F
echo ---------- 开始执行 MongoDB 数据库备份 ----------

rem MongoDB tool directory.
set dumpDir=D:\MongoDB\bin

rem backup path.
set targetDir=F:\data

if not exist %targetDir% (md %targetDir%)

%dumpDir%\mongodump.exe -h 127.0.0.1:27017 -d Petersons      -o  %targetDir%
%dumpDir%\mongodump.exe -h 127.0.0.1:27017 -d PanGu          -o  %targetDir%
%dumpDir%\mongodump.exe -h 127.0.0.1:27017 -d test           -o  %targetDir%

if ERRORLEVEL 0 echo ---------- MongoDB 数据库备份成功 ----------

@echo on
pause

 

相关文章: