mysql dump batch file stopped working.

R

Rob

Hello,
I had someone make a batch file for me that would backup mysql db and
recently it stopped working and I don't know the cause and how to fix it.
The bat file has not changed so it must have been a system change.

The error I get is right after the dump code and it says
The system cannot find the path specified. As I mentioned I can't remember
editing the batch file and the path definitely exists cine I can manually
navigate to the directory in the command prompt.

REM @echo off

for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i

for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
for /f %%i in ('time /t') do set DATE_TIME=%%i
for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump" -u
theusername -p"thepassword" thedbname >"D:\database
backups\thefolder\"%DATE_DAY%_%DATE_TIME%_thedbname.sql

Thanks
 
P

Pegasus \(MVP\)

Rob said:
Hello,
I had someone make a batch file for me that would backup mysql db and
recently it stopped working and I don't know the cause and how to fix it.
The bat file has not changed so it must have been a system change.

The error I get is right after the dump code and it says
The system cannot find the path specified. As I mentioned I can't remember
editing the batch file and the path definitely exists cine I can manually
navigate to the directory in the command prompt.

REM @echo off

for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i

for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
for /f %%i in ('time /t') do set DATE_TIME=%%i
for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump" -u
theusername -p"thepassword" thedbname >"D:\database
backups\thefolder\"%DATE_DAY%_%DATE_TIME%_thedbname.sql

Thanks

There are two path references in the script and you must check
both of them:
C:\Program Files\MySQL\MySQL Server 4.1\bin
and
D:\database backups\thefolder

To make the script more robust, you should add this line right
att the start:
@echo off
if not exist "D:\database backups\thefolder" md "D:\database
backups\thefolder"
 
R

Rob

I added that line like you suggested even though I'm positive both
directories exist. I still receive the same error.
 
P

Pegasus \(MVP\)

Rob said:
I added that line like you suggested even though I'm positive both
directories exist. I still receive the same error.

Create a new batch file like so:
1. @echo off
2. for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i
3. for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
4. for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
5. for /f %%i in ('time /t') do set DATE_TIME=%%i
6. for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i
7. dir "C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump" >
c:\test.txt
8. echo D:\database backups\thefolder\"%DATE_DAY%_%DATE_TIME%_thedbname.sql9. dir "D:\database
backups\thefolder\"%DATE_DAY%_%DATE_TIME%_thedbname.sql" >> c:\test.txt
10. dir "D:\databasebackups\thefolder\"%DATE_DAY%_%DATE_TIME%_thedbname.sql"11. notepad c:\test.txt
12. "C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump" -u
theusername -p"thepassword" thedbname >"D:\database backups\thefolder\"%
DATE_DAY%_%DATE_TIME%_thedbname.sql

You must, of course, remove the line numbers. Their purpose is to
mark the start of each line. Note that Line 12 is a very long line.
Is there a space between "database" and "backups"?

Post the contents of c:\test.txt when it appears on your screen.
 
R

Rob

Volume in drive C is 1
Volume Serial Number is 3C91-1527

Directory of C:\Program Files\MySQL\MySQL Server 4.1\bin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top