OSQL batch scripting

Posted on 2007-10-01
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
    LVL 30

    Accepted Solution

    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

    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

    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
    LVL 32

    Author Comment

    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

    I will try the ammendment...
    LVL 32

    Author Comment

    Excellent - works a treat!!!

    Thank you - nice easy one for you...

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
    Learn about cloud computing and its benefits for small business owners.
    This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
    This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now