新建xxx.bat文件,內容如下: @echo offset hour=%time:~0,2%if "%time:~0,1%"==" " set hour=0%time:~1,1%set now=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%T ...
新建xxx.bat文件,內容如下:
@echo off
set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set now=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%Time:~6,2%
echo %now%
set host=伺服器地址
set port=埠號
set user=MySql用戶名
set pass=MySql密碼
set dbname=資料庫名
set backupfile=保存資料庫文件的路徑(自己設置)\%dbname%-%now%.sql
XXXX(路徑中文件夾名中不能有空格,一般在MySql的安裝路徑bin下)\mysqldump -h%host% -P%port% -u%user% -p%pass% -c --add-drop-table %dbname% > %backupfile%
echo delete files before 90 days
forfiles /p "資料庫文件保存的路徑" /m *.sql /d -90 /c "cmd /c del @file /f"