OSQL batch scripting

Posted on 2007-10-01
Medium Priority
Last Modified: 2013-12-01
We have an issue on a Windows 2003 SP2 server with Symantec BackupExec 11d (with the latest hotfixes installed), with an Sony AIT4 StorStation Library where we get a cleaning tape error on a couple of the backup jobs - but the jobs themselves complete with no issue - except that the error "cleaning media was mounted" is logged - except these slots are not marked as cleaning slots - and the tapes are either brand new or a long erase has been run previously.

We have a single cleaning tape in slot 8 - and when the drive requests a cleaning request - it uses the tape because it is marked as a cleaning slot.

From the Veritas/Symantec knowledgebase - we know that this is a bug that will be fixed in the next major release - but for the time being know that these commands fix the issue.

osql -E -S sgs-sr-backup\bkupexec -d bedb
delete from jobhistorydetail where finalerrordescription like '%library%'

We are looking to script this to run automatically at regular intervals - but the first command has to be run - then the lines after piped into the osql prompt.

Does anyone have an idea how to do this? All suggestions gratefully received.

Question by:and235100
  • 4
  • 2
LVL 30

Accepted Solution

SteveGTR earned 2000 total points
ID: 19993109
You could do this:

@echo off

(echo delete from jobhistorydetail where finalerrordescription like '^%library^%')>_temp.txt
(echo go)>>_temp.txt
(echo exit)>>_temp.txt

osql -E -S sgs-sr-backup\bkupexec -d bedb - i _temp.txt

del _temp.txt

LVL 32

Author Comment

ID: 19993198
Yes, possibly - I can see what that is attempting to do - but will it work? As far as I know - the "osql> " prompt will not take a text file...

I will try this now - and get back to you...
LVL 30

Assisted Solution

SteveGTR earned 2000 total points
ID: 19993244
It will do it if I post the correct syntax. I've got an extra space on the command line :(

osql -E -S sgs-sr-backup\bkupexec -d bedb -i _temp.txt
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

LVL 32

Author Comment

ID: 19993252
I have just tried what you suggested - all that comes up is the list of supported commands for osql.

Any other ideas?
LVL 32

Author Comment

ID: 19993255
I will try the ammendment...
LVL 32

Author Comment

ID: 19993267
Excellent - works a treat!!!

Thank you - nice easy one for you...

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
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…
Suggested Courses

839 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