此脚本配合windows计划任务,可以定时备份网站文件
直接上脚本
@echo off set datevar=%date:~0,4%%date:~5,2%%date:~8,2% MD d:\%datevar% cd C:\Program Files\7-Zip 7z a -t7z D:/%datevar%/wwwroot.7z "D:/wwwroot/*" -m0=BCJ -m1=LZMA:d=21 -ms -mmt
下面是是扫描目录循环打包输出文件
@echo off set datevar=%date:~0,4%%date:~5,2%%date:~8,2% MD d:\wwwroot\%datevar% cd C:\Program Files (x86)\7-Zip for /f "usebackq tokens=1* delims=/" %%a in (`dir /b "D:\wwwroot"`) do 7z a -t7z D:/wwwroot/%datevar%/%%a.7z "D:/wwwroot/%%a" -m0=BCJ -m1=LZMA:d=21 -ms -mmt echo Backup successfly ! pause