RE: mysqldump and batch processing on windows (start /wait /B ....)

"Leigh Sharpe" <[email protected]> Tue, 16 Jan 2007 11:46:15 +1100
Newsgroups gmane.comp.db.mysql.windows
Message-ID <H00000690011bff1.1168908373.mail.pacificwireless.net.au@MHS>
What about using a batch file to do the backups instead? You don't need the 'start' command from within a batch file. That way each command will wait until the previous one finishes.

Alternatively, try using a perl script and invoke the mysqldump facility with backticks. Something like this:

------
#!c:\perl\bin\perl
Use strict;
Use warnings;
My @output=`d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3306 --user=xxxx --password=xxxx --all-databases --verbose --compress`; 
Open (OUTPUT,">backupfile3306.sql") or die "Couldn't open file: $!\n";
Print OUTPUT "@output";
Close OUTPUT or die "Couldn't close file after writing: $!\n";
My @output=`d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3307 --user=xxxx --password=xxxx --all-databases --verbose --compress`; 
Open (OUTPUT,">backupfile3307.sql") or die "Couldn't open file: $!\n";
Print OUTPUT "@output";
Close OUTPUT or die "Couldn't close file after writing: $!\n";
My @output=`d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3308 --user=xxxx --password=xxxx --all-databases --verbose --compress`; 
Open (OUTPUT,">backupfile3308.sql") or die "Couldn't open file: $!\n";
Print OUTPUT "@output";
Close OUTPUT or die "Couldn't close file after writing: $!\n";
My @output=`d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3309 --user=xxxx --password=xxxx --all-databases --verbose --compress`; 
Open (OUTPUT,">backupfile3309.sql") or die "Couldn't open file: $!\n";
Print OUTPUT "@output";
Close OUTPUT or die "Couldn't close file after writing: $!\n";
Print "All done.\n";
---------



Regards,
             Leigh
 
Leigh Sharpe
Network Systems Engineer
Pacific Wireless
Ph +61 3 9584 8966
Mob 0408 009 502
email [email protected]
web www.pacificwireless.com.au

-----Original Message-----
From: Frank Fischer [mailto:[email protected]] 
Sent: Tuesday, January 16, 2007 9:56 AM
To: [email protected]
Subject: mysqldump and batch processing on windows (start /wait /B ....)

Hi all
 
i have a little problem with mysqldump under Windows 2k3. 
 
I have four instances of mysql running which i would like to backup, one
after the other. That means, i would have to start mysqldump app with the
windows "START" command with the "/wait" option to make sure the second dump
just starts after the first dump has finished and so on (at least i see no
other way to do this). Otherwise all dumps would run at the same time.
 
Funny thing is - that only works when calling mysqldump as follows:
 
start /wait /low d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3306
--user=xxxx --password=xxxx --all-databases --verbose --compress >
backupfile3306.sql
start /wait /low d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3307
--user=xxxx --password=xxxx --all-databases --verbose --compress >
backupfile3307.sql
start /wait /low d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3308
--user=xxxx --password=xxxx --all-databases --verbose --compress >
backupfile3308.sql
start /wait /low d:\mysql-slave\bin\mysqldump --host=127.0.0.1 --port=3309
--user=xxxx --password=xxxx --all-databases --verbose --compress >
backupfile3309.sql
 
 
Now - like this each mysqldump runs after another, but, unfortunally no data
is written to the target files. What i see, is that a new console window is
opened and the backup data is written to this window instead of to the file.

 
So i changed the batch commands a little bit. I just added "/B" to the start
command:
 
start /wait /low /B d:\mysql-slave\bin\mysqldump --host=127.0.0.1
--port=3306 --user=xxxx --password=xxxx --all-databases --verbose --compress
> backupfile3306.sql
start /wait /low /B d:\mysql-slave\bin\mysqldump --host=127.0.0.1
--port=3307 --user=xxxx --password=xxxx --all-databases --verbose --compress
> backupfile3307.sql
start /wait /low /B d:\mysql-slave\bin\mysqldump --host=127.0.0.1
--port=3308 --user=xxxx --password=xxxx --all-databases --verbose --compress
> backupfile3308.sql
start /wait /low /B d:\mysql-slave\bin\mysqldump --host=127.0.0.1
--port=3309 --user=xxxx --password=xxxx --all-databases --verbose --compress
> backupfile3309.sql
 
 
Now again a funny behaviour - this time there are no new console windows
opened and the backup data is written to the target files, but now instead
of waiting until a mysqldump process has ended before starting the next, the
batch just starts one after another so all are running at the same time. 
 
Working with CALL instead of START or even with CALL in combination with
START doesn't change anything in this behaviour. 
 
Does anyone has an idea what i'm doing wrong? Any other way to do what i
would like (i have to add that i also need to control process priority)?
 
Thanks a lot for your help
Frank
 
 


-- 
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe:    http://lists.mysql.com/[email protected]