gregnottage Posted April 19, 2007 Share Posted April 19, 2007 (edited) Hi Guys, I've written a couple of scripts to try and tame NTBackup running on Windows Server 2003 (SP2). I have a single SDLT drive attached to my backup server, and the only way I can reliably get NTBackup to perform Normal (Full) backups is to run them interactively. This seems to be because NTBackup (& RSM) was designed to work with tape autoloaders. Therefore when you run a Full NTBackup job as a scheduled task, it fails when the backup requests a second tape. Having worked through all of the MS recommendations on the relevant KB articles, I decided that I'd try my hand at writing an AutoIt script to help me out. Please see the following scripts: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.2.0 Author: Greg Nottage Script Function: Automate NTBackup Media Overwrite prompts. #ce ---------------------------------------------------------------------------- ; Script Start ;Set AutoIt options AutoItSetOption("TrayIconDebug", 1); Show debug info in tray icon AutoItSetOption("WinTitleMatchMode", 2); 2 = Match any substring in title AutoItSetOption("TrayIconHide", 0); 0 = do not hide, 1 = hide tray icon ;Run in a permanent loop waiting for conditions to exist While 1 Select ;Check if the NTBackup media warning message is present Case WinExists ("Backup Utility", "There is no free media available") ;Pause for half a second Sleep(500) ControlClick("Backup Utility", "There is no free media available", 6); Click the Yes button ;Check if the NTBackup Replace Data warning message is present Case WinExists ("Replace Data", "Warning: All of the data will be replaced") ;Pause for half a second Sleep(500) ControlClick("Replace Data", "Warning: All of the data will be replaced", 6); Click the Yes button EndSelect WEnd expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.2.0 Author: Greg Nottage Script Function: Interactively runs NTBackup and performs a Normal (Full) Backup job Usage: requires jobname to be set as a paramater when running the script i.e.: NTBackup_Full.au3 "Weekly_Full" #ce ---------------------------------------------------------------------------- ;Script Start ;Set AutoIt options AutoItSetOption("TrayIconDebug", 1); Show debug info in tray icon AutoItSetOption("WinTitleMatchMode", 2); 2 = Match any substring in title AutoItSetOption("TrayIconHide", 0); 0 = do not hide, 1 = hide tray icon ;Set Variables $NTB =@SystemDir & "\ntbackup.exe" $JobPath = "C:\Backup Jobs\Full_Backup.bks" $JobName = $cmdline[1] ;Run NTBackup and start the backup Run($NTB, "", @SW_MAXIMIZE);Shows NTBackup Maximised WinWait("Backup Utility -", "Untitled");Pause script until NTBackup window is visible WinActivate("Backup Utility -", "Untitled"); Ensure the NTBackup window has the focus Send("^{TAB}"); Sends a Ctrl+TAB to switch to backup tab WinActivate("Backup Utility -", "Untitled"); Ensure the NTBackup window has the focus Send("!j"); Open the Job menu Send("l"); Open the load job dialogue box WinWait("Open","") Send($JobPath); Insert the full path to the NTBackup job file Sleep(500); Pause for half a second Send("!o"); Click the Open button WinActivate("Backup Utility -", "Full_Backup.bks"); Ensure the NTBackup window has the focus Send("!s"); Click the Start Backup button WinWait("Backup Job Information", "&Start Backup"); Pause script until the Start Backup dialogue appears ControlSetText("Backup Job Information", "&Start Backup", 4045, $JobName); Set the job description ControlSetText("Backup Job Information", "&Start Backup", 4044, $JobName); Set the media label ; Ensure backup type is set to Normal (i.e. Full backup of all files) ControlClick("Backup Job Information", "&Start Backup", 1274); Click the Advanced button WinWait("Advanced Backup Options", "OK"); Pause script until the Advanced Backup Options dialogue appears ControlSend("Advanced Backup Options", "OK", 1284, "n"); Ensure Normal job type selected in combobox ControlClick("Advanced Backup Options", "OK", 1); Click the OK button ControlClick("Backup Job Information", "&Start Backup", 1); Click the Start Backup button ;Script End I've compiled them both into standalone exe's. The first script I have running all the time so that it takes care of the NTBackup tape messages whenever they appear. The second script I have setup as a scheduled task that runs only when I'm logged in. I have a couple of questions regarding improvements to the above scripts. Firstly, is it possible to combine the scripts into one single script? I don't know if you can have the loop running in the background waiting for the NTBackup tape messages whilst the main part of the script runs the backup? Also, is there a less processor intensive way of performing the loop, rather than a while 1 loop? This seems to demand a lot of processor cycles on my backup server and I wondered if there was a more efficient way of doing it? I had thought about removing the while 1 statement, and then running that script as a scheduled task every so often? Please let me know if you can suggest some improvements to my scripts and the above solution. Many thanks, Greg. Edited April 19, 2007 by gregnottage Link to comment Share on other sites More sharing options...
ptrex Posted April 19, 2007 Share Posted April 19, 2007 @gregnottage I run this command on an WIN 2003 R02 Server and no problem. Try to run this script first in a .Bat file before automating it in AU3. See if it works. start /wait C:\WINDOWS\system32\NTBACKUP.EXE backup "@C:\Admin\Backup.bks" /n "Full Backup" /d "Full Backup - SRVPLSK03" /v:no /r:no /rs:no /hc:on /m normal /j "Backup" /l:f /p "SDLT" /UM There is a NOT DOCUMENTED switch you can use called /UM. This is the statement of Microsoft about it "Microsoft strongly recommends that you use managed media. Unmanaged media is still supported in Windows Server 2003, but Microsoft removed the documentation for it from the help file so they must feel pretty strongly about it." Enjoy !! ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now