2

I'm running a batch file to back up some mysql databases on a 2012 webserver. The batch file creates a folder, then runs the following for each db:

mysqldump -u *username* -p*Password* *db_name* > C:\folder&filename-%date:~-2,4%-%date:~-7,2%-%date:~-10,2%.sql

This works fine when I manually run the bath file, however when I run the same batch file in task scheduler I get 0kb databases with no content. The folder is created, as is the xyz.sql files, but thats it.

The exact same script is working fine on my 08 server.

Any ideas? Thanks

4
  • I'm going to see if I can help you with this one, but in the mean time here is an example of something similar I had. I had a VB script that I was trying to run from the server as a scheduled task and if I manually ran it, it would work just fine. However, when I put it as a scheduled task it wouldn't work even though the task said it ran. I found out the program for the scheduled task I had to run was CSCRIPT and then put the path (in quotes) to the actual VB script as an argument to get it to work properly... May 19, 2014 at 21:20
  • ... I also had to run it with Highest Privileges (which meant the user I ran it as needed log on as a batch/service rights), but once I did that it worked just fine. You might try running CMD.exe as your program with the full path to the batch file as the arguments and see if it works. May 19, 2014 at 21:21
  • Thanks. This sent me on a wild goose chase that answered the issue as described below. Putting it down to a late night & square eyes!
    – Mr T
    May 21, 2014 at 21:24
  • Glad we could get you on the right path my friend. May 21, 2014 at 21:33

2 Answers 2

0

Had this a couple of times.

Open up your local security policy > local policies > user right assignment

Go to "Log on as a batch job", add the user account that you are running the scheduled task as and test.

(Better yet, create a service account specific to this task and use this)

1
  • I'm running as administrator with Highest Privileges set & the task set to run with highest privileges. I've checked secpol & administrator is there (as you would expect).
    – Mr T
    May 21, 2014 at 21:06
0

I've solved the issue. The batch file didn't appear when running the task scheduler, so I couldn't see what was going on. Brads suggestion of creating a batch file to run the batch file popped up the script & I could see the issue immediately. It couldn't find the mysqldump app, which wasn't in the cmd current directory (system32).

I added cd c:\folderlocationofmysqldump & problem solved. Thanks for the help guys.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .