robocopy和计划任务并用实现文件服务器每天自动备份


@echo off
1、BAT文件
robocopy "\\10.15.0.4\e$\Backup" "\\10.15.0.5\J$\DLExBackup" *.* /e /copyall /V /Mir /NP /s /LOG+:"i:\RobocopyLogs\exchange.log" /Z /R:10 /W:30
#robocopy实现源文件夹内容完全COPY到目标文件夹中,并在指定目录中生成日记文件!
For /F %%i In ('date /t') do ren i:\RobocopyLogs\exchange.log exchange%%i.log
#用FOR循环实现对生成的日记文件名改名,以当天的日期做为你的文件名,便于查看,也便于下面的FORFILES的执行!
start i:\automail1.vbs
#automail1.vbs实现的是执行完备份操作后发一封邮件,以保证备份的正常结束!
forfiles /p i:\RobocopyLogs /m *.log -d -7 /c "cmd /c del /f @path"
#用forfiles删除七天前的日记文件,以免日记文件过大,占用过多的磁盘空间!
2、automail1.vbs脚本内容如下:
NameSpace = " http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "[email protected]"
objEmail.To = "[email protected]"
objEmail.Subject = "服务器BAT备份完毕"
objEmail.Textbody = "服务器BAT备份完毕."
With objEmail.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "10.15.0.10"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 0
.update
End With
objEmail.Send

最新能发邮件的脚本

NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
Email.From = "******
@sina.com"
Email.To = "*******
@sina.com"
Email.Subject = "Test sendmail.vbs"
Email.Textbody = "OK!"
'Email.AddAttachment "C:\foo.zip"
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "smtp.sina.com"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "**********"
.Item(NameSpace&"sendpassword") = "**********"
.Update
End With
Email.Send


你可能感兴趣的:(服务器,backup,文件夹,start,源文件)