Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Running a backup Script in Windows Server 2008

Posted on 2010-09-21
6
Medium Priority
?
969 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

916 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