@echo on
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%
set now1=%Date:~0,4%%Date:~5,2%
set host=IP地址
set port=3306
set user=用户名
set pass=密码
set dbname=pm
md e:\pm_backup\db\%now1%
set backupfile=e:\pm_backup\db\%now1%\%dbname%-%now%.sql
set backupfile_rar=e:\pm_backup\db\%now1%\%dbname%-%now%.rar
mysqldump --no-defaults -h%host% -P%port% -u%user% -p%pass% %dbname% > %backupfile%
rar a -ep %backupfile_rar% %backupfile%
del %backupfile%
rem echo delete files before 60 days
rem forfiles /p "e:\pm_backup\db" /m *.sql /d -60 /c "cmd /c del @file /f"