[SQL] Backup batch file for MySQL on Windows
ECHO MySQL Start Backup
FOR /F "tokens=1-3 delims=- " %%a IN ('DATE /T') DO (SET dt=%%a-%%b-%%c)
FOR /F "tokens=1-4 delims=:." %%a IN ('ECHO %TIME%') DO (SET tm=%%a%%b%%c%%d)
SET backupfilename=_%dt%_%tm%.sql
ECHO Backup file name: %backupfilename%
mysqldump --routines -u[username] -p[password] [database_name] > C:\BackupData\"dbname%backupfilename%"
ECHO Delete old backup files
FORFILES /P E:\data\backup /S /M *.sql /D -3 /C "cmd /c del @file"
ECHO Finish Backup