Reputation: 6688
I'm trying to create a batchfile that does a mysqldump with a timestamp filename.
I have tried:
mysqldump -uuser -ppassword database > C:\backup\%DATE%.sql
I get error:
C:\backup\06/18/13.sql
Which gives me an error:
The system cannot find the path specified.
Which I assume is because of the forward slashes. I've tried using set to set DATE and then invoke it in the mysqldump line, but then batch file crashes.
Upvotes: 0
Views: 1517
Reputation: 92785
Try (mysqlbackup.bat
):
@echo off
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
for /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
mysqldump -uuser -ppassword database > C:\backup\%mydate%_%mytime%.sql
Courtesy to https://stackoverflow.com/a/203116/1920232
Upvotes: 4