Solved

Running a backup Script in Windows Server 2008

Posted on 2010-09-21
6
946 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

A safe way to clean winsxs folder from your windows server 2008 R2 editions
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

739 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