Simple Script to backup MySQL Databases

16 Mar

This is a simple script I use to backup MySQL databases.

Save the following as backup.bat (or similar) and they you can set a scheduled task to run this daily.

“C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump.exe” -uUSERNAME -pPASSWORD MYSQLDBNAME > “c:\folder\mysqldbname\mysqldbname_%time:~0,2%%time:~3,2%%time:~6,2%_%date:~-10,2%%date:~-7,2%%date:~-4,4%.sql”

The script will then login to the MySQL server with USERNAME and PASSWORD and take a copy of the database MYSQLDBNAME and place it in c:\folder\mysqldbname with the filename “mysqldbname_TIME_DATE.sql”

Very straight forward and very effective.