Automate MySQL backup @localhost with mysqldump in Windows 8

625 Views Asked by At

I'm trying to set up a task in Windows 8 to automate my localhost db dump. I've created the task to run daily with the following command line:

C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe

and parameters:

--user=root --password=donttellya --result-file=dumped.sql mydb  

It works but doesn't terminate (running in the tasks list).

Also, I'd like to set a different name for the dumped file each day, maybe with the following pattern:

mydump-yymmdd-hhmmss.sql

How do you do that?

1

There are 1 best solutions below

0
On BEST ANSWER

I think I've found it.

The command to give to the scheduler is cmd.exe. In the parameters, the command file to be executed:

/C commandfile.cmd

And in commandfile.cmd add date and time (without the slashes, depending on your local settings):

@echo off

set YEAR=%DATE:~6,4%
set MONTH=%DATE:~3,2%
set DAY=%DATE:~0,2%

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe" --user=youruser --password=yourpwd --result-file=yourpath\backup-%YEAR%-%MONTH%-%DAY%-%time%.sql yourdb