Solved

Running a backup Script in Windows Server 2008

Posted on 2010-09-21
6
938 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

791 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