Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

move command in batch script will not work when run as scheduled task

Status
Not open for further replies.
Feb 4, 2011
53
CA
Greetings all,
I have a bat file that I use to make a backup of an SQLexpress database. The backup is done to a local disk. I then initiate a move command to move the files to a shared folder on another system. For some reason when running it via a scheduled task, the move command either doesn't run or cannot move for one reason or another. Below is my script, any help is appreciated.

Code:
@ECHO OFF

echo %date% >> "C:\batch files\script.log"

net use Z: /DELETE >> "c:\batch files\script.log"
net use z: \\san-proxy\SQL_Backups\mtg-svr >> "c:\batch files\script.log"

REM forfiles /p "Z:\" /m *.BAK /d -2 /c "cmd /c DEL @file"

sqlcmd -E -Q "EXEC sp_BackupDatabases @backupLocation='D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\', @backupType='F'" >> "C:\batch files\script.log"

move "D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\*.BAK" z:\ >> "C:\batch files\script.log"

echo %date% >> "C:\batch files\script.log"

echo "C:\batch files\script.log"
:echo "C:\batch files\script.log"
 
Can you post the script.log file.

-------------------------------

If it doesn't leak oil it must be empty!!
 
Here is the script.log that I am creating these are the last few entries:
Code:
Tue 12/13/2011 
Z: was deleted successfully.

The command completed successfully.

Processed 61872 pages for database 'ps424', file 'powerseller_Data' on file 1.
Processed 4 pages for database 'ps424', file 'powerseller_Log' on file 1.
BACKUP DATABASE successfully processed 61876 pages in 28.226 seconds (17.126 MB/sec).
Processed 184 pages for database 'PSAuthenticate', file 'PSAuthenticate' on file 1.
Processed 1 pages for database 'PSAuthenticate', file 'PSAuthenticate_log' on file 1.
BACKUP DATABASE successfully processed 185 pages in 0.347 seconds (4.165 MB/sec).
Tue 12/13/2011 


Wed 12/14/2011 
Z: was deleted successfully.

The command completed successfully.

Processed 62008 pages for database 'ps424', file 'powerseller_Data' on file 1.
Processed 6 pages for database 'ps424', file 'powerseller_Log' on file 1.
BACKUP DATABASE successfully processed 62014 pages in 31.976 seconds (15.151 MB/sec).
Processed 184 pages for database 'PSAuthenticate', file 'PSAuthenticate' on file 1.
Processed 1 pages for database 'PSAuthenticate', file 'PSAuthenticate_log' on file 1.
BACKUP DATABASE successfully processed 185 pages in 0.405 seconds (3.568 MB/sec).
Wed 12/14/2011
 
Check the permissions of the account the task is running with on the both the d:\ folder and the z:\ drive. Remember when moving a file it needs the rights to delete it.

Can't think of anything else that would be stopping it from working.

-------------------------------

If it doesn't leak oil it must be empty!!
 
Thanks for the replies. The task is running as the domain administrator.
 
Ok, so I have verified permissions. I even changed the task to a Windows 2008 R2 task. Still no improvement. I have added "2>&1" to the end of each statement to see if I get any errors recorded in my log file so I can see what is the matter. I will report back next week after this has run a few times.
 
I have resolved this issue. I recreated the task and now it is all working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top