Solved

Running a backup Script in Windows Server 2008

Posted on 2010-09-21
6
929 Views
Last Modified: 2012-05-10
I have two files 1) May10_Backup.cmd 2) May10.vbs. The cmd file runs the vbs file when executed.

I was able to execute the script in Windows Server 2003 successfully but cannot in Windows Server 2008. Something must be blocking them. Is there setting that I need to disable or enable? I am using a scheduling agent in SQL Server Management Studio. I can provide the files if needed. Thank you!
0
Comment
Question by:Jintonix415
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 33729274
Should run...As a wild guess, I'd say that the two launches do not have the same security authorization to run the server side TSQL script.  Make sure the SQL Agent service account AND/OR the session lauching the CMD file has a matching login/user and credentials in SQL Server.  posting the CMD and VBS would indeed help...
0
 

Author Comment

by:Jintonix415
ID: 33729432
This is the cmd file:

Rem ** backup May10 DBs to f:\backup\* **

c:\windows\syswow64\wscript.exe d:\May10.vbs

xcopy f:\backup\May10*.zip \\servername\qrm\ /D:04-23-2009 /Y /S

exit

Here is the vba code:

'BEGIN SCRIPT
'Declare framework scripting object variable
Dim fso
Dim objQRM , cDbaseName
Dim LogName, LogFile
' Change the value below to the database name in the CA
cDbaseName = "May10"
set objQRM = createObject("QRM.RiskFramework.161")
IF IsNull(objQRM) Then
   Msgbox ("Failed to create COM object")
   wscript.quit(1)
End if
'Set up log file to record any error messages or information

'Now() returns current time stamp

set fso = CreateObject("Scripting.FileSystemObject")

set LogFile = fso.CreateTextFile("F:\backup\May10.txt", True)

LogFile.WriteLine(Now() & " Begin script")

'Log in to the framework database.

'If login fails, write error message into log file and exit from the script. 'Otherwise, write success message into log file

If objQRM.Login(cDbaseName) = FALSE Then
  LogFile.WriteLine(Now() & " Login failed: " & objqrm.CERRMSG)
   LogFile.WriteLine(objqrm.ErrorDetails)
   Call objQRM.Logout()
   wscript.quit(1)
End If
LogFile.WriteLine(Now() & " Login pass")
' Change the value below to the database name in the CA and change the location of the backup directory
If objQRM.BackupCADatabase("May10", "\\cpwbp2014\f$\backup\") = FALSE Then
  LogFile.WriteLine(Now() & " Backup DB Failed " & objqrm.CERRMSG)
  LogFile.WriteLine(objqrm.ErrorDetails)
 Call objQRM.Logout()
 wscript.quit(1)
End If
LogFile.WriteLine(Now() & "Database Backup Successful")

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 33730395
Is your CMD file being run?  If so, is your VBS executing after that?  Does the
F:\backup\May10.txt
log file get created?

In the batch file, under the first REM line, add
echo Batch started >> F:\backup\May10_batch.txt

and that will output to May10_batch.txt so you know if the batch is running.

We'll go from there once we get more info from you.

Regards,

Rob
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Jintonix415
ID: 33736188
I have added this statement to the cmd file but it did not output a batch file. Are there compatibility issues with SQL Server Management Studio and Windows Server 2008 Service Pack 2 64 bit perhaps?

Rem ** backup May10 DBs to f:\backup\* **

echo Batch started >> F:\backup\May10_batch.txt

c:\windows\syswow64\wscript.exe d:\May10.vbs

xcopy f:\backup\May10*.zip \\wfsmnsv2nnf25\qrm\ /D:04-23-2009 /Y /S

exit
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 33741124
I guess it should work as long as you're scheduling it using a process like this:

How to: Schedule a Job (SQL Server Management Studio)
http://msdn.microsoft.com/en-us/library/ms191439.aspx

Or maybe this would help
How to: Run a Package Using a SQL Server Agent Job
http://msdn.microsoft.com/en-us/library/ms139805(SQL.90).aspx

It states the following:
"For example, you want to run a package from a 64-bit SQL Server Agent job in 32-bit mode. For Type, select Operating system (CmdExec), and then enter a command line that invokes the 32-bit version of the dtexec utility."

which you could use as an option to run your batch file.

Regards,

Rob.
0
 

Author Closing Comment

by:Jintonix415
ID: 33780125
Thanks! It was running in a 64 bit environment from 32.
0

Featured Post

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now