青云 发表于 2012-7-28 09:35:42

HZ65自动备份定时清理

net stop MSSQLSERVER /y
"C:\Program Files\WinRAR\Rar.exe" a-k -r -s -m1 -inul "E:\BAKUP\SQLData\SJQY%date:~0,10%.RAR" "E:\db\"
xcopy "E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\hz65.ldf" "E:\BAKUP\SQLData\HZ65\" /e /i /q
xcopy "E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\hz65.mdf" "E:\BAKUP\SQLData\HZ65\" /e /i /q
net start MSSQLSERVER
net start SQLSERVERAGENT
"C:\Program Files\WinRAR\Rar.exe" a-k -r -s -m1 -inul "E:\BAKUP\SQLData\HZ65%date:~0,10%.RAR" "E:\BAKUP\SQLData\HZ65\"
del "E:\BAKUP\SQLData\HZ65\*.*" /s /q
"C:\Program Files\WinRAR\Rar.exe" a-r -s -m1 -o+ -inul "E:\BAKUP\SQLData\sjqy_backup.rar" "E:\BAKUP\SQLData\sjqy_backup.bak"
del "E:\BAKUP\SQLData\sjqy_backup.bak" /s /q
"C:\Program Files\WinRAR\Rar.exe" a-r -s -m1 -o+ -inul "E:\BAKUP\SQLData\hz65_backup.rar" "E:\BAKUP\SQLData\hz65_backup.bak"
del "E:\BAKUP\SQLData\hz65_backup.bak" /s /q

forfiles /p E:\BAKUP\SQLData /m *.* -d -7 /c "cmd /c del /f @path"

safeidc 发表于 2012-8-10 09:52:36

不错 收藏!

青云 发表于 2013-4-24 10:58:57

删除备份目录7天以前的BAK文件!forfiles /p "E:\beifen" /S /m *.bak -d -7 /c "cmd /c del /f @path"
页: [1]
查看完整版本: HZ65自动备份定时清理