用bat实现定时执行任务的批处理文件
(编辑:jimmy 日期: 2024/11/13 浏览:2)
@echo off
set txt1=%date:~0,4%
::当前年
set txt2=%date:~5,2%
::当前月
set txt3=%date:~8,2%
::当前日
set txt4=%time:~0,2%
::当前小时
set txt5=%time:~3,2%
::当前分钟
set txt6=%time:~6,2%
::当前秒
set date=%txt1%%txt2%%txt3%
set time=%txt4%%txt5%%txt6%
echo --------------------------------------------------
echo -------------正在执行MySQL数据库备份--------------
echo --------------------------------------------------
echo ...
echo ...
echo 导出Database...
if exist %date%.sql del %date%.sql
c:\Progr*\mysql\bin\mysqldump --add-drop-table -c -u root -p-h localhost dbname >e:\%date%.sql
echo ...
echo ...
if exist dump%date%.7z del dump%date%.7z
echo 压缩文件...
7za.exe a -t7z dump%date%.7z %date%.sql -mx9
echo ...
echo ...
echo 删除临时文件
del %date%.sql
echo ...
echo ...
echo 备份完成!
pause