查看单个帖子
lminz
 
lminz 的头像
热心会员
 
资 料:
注册日期: May 2002
帖子: 4,921 声望值: 3
精华: 0,解答: 4
#26 旧 2021-02-27, 16:40:31 默认
lminz 当前离线  

引用:
作者: xclimbing 查看帖子
那就取得这个周五(当天)的日期,然后用我前面的批处理做一个减7天的操作不就完成任务了。
你看看是否有要改善的
红色日期我是手动改了测试的,正常换回%date%,每周五运行
暂时测试可以


代码:
@Echo Off
Echo NewDate = DateAdd^("d", Wscript.arguments^(1^), Wscript.arguments^(0^)^)>Day.vbs
Echo Wscript.Echo NewDate>>Day.vbs
echo set basedate=2021-02-26>basedate.bat

call basedate.bat
if not defined basedate set basedate=%date%
echo Current date:%basedate%
set dayadd=-7

for /f "tokens=*" %%i in ('cscript /nologo Day.vbs %basedate% %dayadd%') do (set nextdate=%%i)
::if %date% GEQ %nextdate% set basedate=%nextdate%
::echo set basedate=%basedate%>basedate.bat

set fullbakday=%basedate:~,4%%basedate:~5,2%%basedate:~8,2%
set today=%date:~,4%%date:~5,2%%date:~8,2%
set lastday=%nextdate:~,4%%nextdate:~5,2%%nextdate:~8,2%
echo Last full backup date:%basedate%

echo today:%today%
echo fullbakday:%fullbakday%
echo lastday:%lastday%
Del /q Day.vbs
Del /q basedate.bat

C:\WinRAR\WinRAR.exe a -m4 密码 H:\路径\%lastday%systemdb_log.rar \\IP地址\DBbackup\%lastday%systemdb_log.bak
C:\WinRAR\WinRAR.exe a -m4 密码 H:\路径\%fullbakday%systemdb.rar \\IP地址\DBbackup\%fullbakday%systemdb.bak

此帖于 2021-02-27 16:46:57 被 lminz 编辑. .


http://blog.06108.cn
回复时引用此帖