Backing up mySQL Databases Batch File / Script

4 Jul

And another, this time to backup the databases, based on an earlier post or creating simple backups, I can then call this batch from within another batch file.

@echo off

IF %1.==. GOTO No1

ECHO Dave’s mySQL Database Backup Utility
ECHO ————————————-
ECHO Backing Up Database %1
ECHO ————————————-
 
“C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe” -uroot -pPASSWORD %1 > “c:\directory\%1\%time:~0,2%%time:~3,2%%time:~6,2%_%date:~-10,2%%date:~-7,2%%date:~-4,4%.sql”

ECHO Done

GOTO End1

:No1
  ECHO No database Sepecified
  ECHO use: bmsql.bat DATABASENAME
GOTO End1

:End1

The multiple backup file then looks something like this:

call bmysql DB1

call bmysql DB2

call bmysql DB3