Solved

Running a backup Script in Windows Server 2008

Posted on 2010-09-21
6
955 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

630 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