参考各种网站的建议,得到下面的脚本,他可以备份最近一周的脚本,分别放到week1到week7的目录里,适当修改一下可以备份任意期间的系统。
让task schedule每天自动执行backupsystem.bat就OK了。
主脚本:BackupSystem.bat
@echo off
::BackupSystem.bat
::demonstration script using WBADMIN.EXE on a
Windows Server 2008 Server
rem backup share UNC
set backupshare=\\mycompany-dc01\Backup
rem files and folders to include
set include=c:,d:
rem define date time variables for building the folder name
set m=%date:~5,2%
set d=%date:~8,2%
set y=%date:~0,4%
set h=%time:~0,2%
set min=%time:~3,2%
set sec=%time:~6,2%
FOR /F "tokens=*" %%A IN ('CSCRIPT c:\temp\WEEK.VBS //NoLogo') DO SET %%A
rem defining a new folder like \\mycompany-dc01\backup\RESEARCHDC\20091215_132532
set newfolder=%backupshare%\%computername%\Week%Week%
echo Creating %newfolder%
mkdir %newfolder%
rem run the backup
echo Backing up %include% to %newfolder%
wbadmin start backup -backuptarget:%newfolder% -include:%include% -vssFull -quiet
rem Clear variables
set backupshare=
set include=
set m=
set d=
set y=
set h=
set min=
set sec=
set newfolder=
星期取得脚本:WEEK.VBS
Wscript.Echo("Week=" & DatePart("w",Date,vbMonday,vbFirstJan1))