windows定时批处理加密压缩
目标:完成在每天数据库备份之后,对备份文件进行定时压缩打包。用以下代码实现此项功能。
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set password="123"
"C:\Program Files\WinRAR\WinRAR.exe" a -ibck -m4 -p%password% C:\backup\web\nuoha%Ymd%.zip C:\wwwroot\youquya_oxz32t\web
"C:\Program Files\WinRAR\WinRAR.exe" a -ibck -m4 -p%password% C:\backup\web\wzdao%Ymd%.zip C:\home\ftp\w\wzdao\wwwroot
计划运行备份脚本。
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2023-11-08T20:41:09.1100491</Date>
<Author>10-7-137-196\Administrator</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2023-11-08T02:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>10-7-137-196\Administrator</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\Administrator\Desktop\文本文档.bat</Command>
</Exec>
</Actions>
</Task>