21
10
I am running a program from a batch file, which when it is done performs an automatic backup of my MySQL database.
I would like the batch file to create a different back up for each run, so I can backtrace.
The desired filename would be gnucash_shockwave-20121128210344.sql (Date format YYYY-MM-DD-HH-MM-SS)
I have googled a few things that said try %DATE:~4% and %Date.Year% but I get an error that says The system cannot find the specified path.
If I remove the attempt to timestamp it, the script works fine, but over writes the previous backup
Here is the section of code I'm talking about:
@REM *** EXECUTION ***
echo. Starting backup...
SET timestamp %DATE:~-4%%DATE:~4,2%%DATE:~7,2%%TIME%
%mysqldir%\mysqldump -u %mysqluser% -p%mysqlpassword% -h %mysqlhost% -P %mysqlport% --databases --routines --verbose gnucash_shockwave > %BackupDir%\gnucash_shockwave-%timestamp%.sql
echo.------------------------------------------------------
echo. Backup complete!
Any suggestions?
replacing %date% by %date:~6,4%-%date:~3,2%-%date:~0,2% worked – MagTun – 2015-11-27T10:05:43.420
I've reassociated your accounts, you should be able to log in and comment on your own posts and answers to your questions now. – slhck – 2012-11-29T21:18:30.767
slhck, lol thanks i was wondering what was going on then I remembered I wasn't at stack overflow lol – guyfromfl – 2012-11-29T21:36:52.997