备份MongoDB并同步到SkyDrive
(创建时间:2013年06月06日 10:53:46)
Jangogo : 

备份MongoDB并同步到SkyDrive

on error resume next
dim objShell,fso,fn,Nw,fd,sf,f1
''执行MongoDB备份
set objShell=CreateObject("Wscript.Shell")
objShell.Run "C:\mongodb\bin\mongodump.exe -h 127.0.0.1 -d db4 -o ""Z:\SkyDrive\MongoDB Backup"" -u myuser -p mypassword",0,true
objShell.Sleep 3000
''拷贝多一份副本到Z:\mongobackup\
Nw=Now()
fn= "Z:\mongobackup\" & Year(Nw) & "-" & Month(Nw) & "-" & Day(Nw) & "." & hour(Nw) & "." & Minute(Nw) & "." & Second(Nw)
set fso=CreateObject("Scripting.FileSystemObject")
fso.CreateFolder fn
fso.CopyFolder "Z:\SkyDrive\MongoDB Backup",fn
objShell.Sleep 3000
''清理一下E:\mongobackup\,最多保留4份拷贝
'获取最后一次修改的时间
set fd = fso.GetFolder("Z:\mongobackup\")
Set sf = fd.SubFolders
For Each f1 in sf
if datediff("d",f1.DateLastModified,Nw)>5 then
f1.Delete
end if
Next
set f1=nothing
set fd=nothing
set fs=nothing
set fso=nothing
set objShell=nothing

mongodb备份