FUNCTION good_date,date,date_name good_date=(N_ELEMENTS(date) EQ 1) AND (STRLEN(date) GE 8) IF good_date THEN BEGIN date=STRTRIM(date,2) date_len=STRLEN(date) mflag=isnumber(STRMID(date,0,2),month) good_month=(mflag NE 0) AND $ ((1 LE month) AND (month LE 12)) good_delim=STRMID(date,2,1) EQ '/' dflag=isnumber(STRMID(date,3,2),day) good_day=dflag NE 0 good_delim=good_delim AND (STRMID(date,5,1) EQ '/') yflag=isnumber(STRMID(date,6,2),year) good_year=(yflag NE 0) AND (year GE 0) IF good_year THEN BEGIN IF year LT 50 THEN year=2000+year IF year GE 50 THEN year=1900+year ENDIF good_day=(dflag NE 0) AND $ ((1 LE day) AND (day LE monthdays(year,month))) good_date=good_month AND good_day AND good_year AND good_delim IF good_date AND (date_len GT 8) THEN BEGIN good_delim=STRMID(date,8,1) EQ ':' hflag=isnumber(STRMID(date,9,2),hour) good_hour=(hflag NE 0) AND $ ((0 LE hour) AND (hour LE 23)) good_date=good_delim AND good_hour ENDIF IF good_date AND (date_len GT 11) THEN BEGIN good_delim=STRMID(date,11,1) EQ ':' mflag=isnumber(STRMID(date,12,2),minute) good_minute=(mflag NE 0) AND $ ((0 LE minute) AND (minute LE 59)) good_date=good_delim AND good_minute ENDIF ENDIF IF NOT good_date THEN BEGIN mess=STRING(date_name,date,FORMAT='(A," format error: ",A)') MESSAGE,mess,/INFORMATIONAL ENDIF RETURN,good_date END ; --------------------------------------------------------------------- ;+ ; NAME: ; NOVASTOR ; PURPOSE: ; Allow access to data on NovaStor backup tapes under control of IDL. ; CATEGORY: ; Tape access; archive creation/restoration. ; CALLING SEQUENCE: ; NOVASTOR,PROGRAM,TAPE=tape,SET=set,AFTER=after,BEFORE=before $ ; ,THERM=therm,LOG=log,UNIT=unit,LAST=last,REPLACE=replace $ ; ,BATCH=batch,FILES=files,SUB=sub,REWIND=rewind,TOEND=toend $ ; ,COMPLETE=complete,NEW=new,QUICK=quick,PAUSE=pause ; INPUTS: ; PROGRAM: Specifies the name of the NovaStor command line interface ; program to run (one of BKP, RST, BVER, TLST). ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; The domain of validity of the keywords below is encoded as follows: ; A: All; B: BKP; R: RST; V: BVER; T: TLST ; ; TAPE: (A) The tape name (as recorded on the label); this is used ; in naming the .BAT and log files. ; SET: (RVT) The backup set number to be processed on the tape. ; AFTER: (BR) Specifies (for BKP and RST) the start date/time for ; the files to be processed. ; BEFORE: (BR) Specifies (for BKP and RST) the end date/time for the ; files to be processed. ; /THERM: (B) Display percentage of backup completed as a thermometer. ; LOG: (A) Sets the level of detail to return in log/list files; ; LOG=0 => no logging; LOG=1 => subdirectories only; LOG=2 ; => all files. ; UNIT: (A) Specifies the SCSI unit number of the tape drive (0-31). ; /LAST: (RV) Restore or verify the last unit on the tape. ; REPLACE: (R) Overwrite (1) or do NOT overwrite (-1) existing files ; with those from the tape where the file names are equal. ; BATCH: (BR) Specifies the backup procedure to be executed. ; FILES: (BR) Specifies the directories/files to be backed up or ; restored. For the correct syntax see the NovaBack manual, ; pp. 91-97. ; /SUB: (BR) Process files in subdirectories of specified volumes/ ; directories. ; REWIND: (BRV) Rewind (1) or do NOT rewind (-1) the tape before ; running the specified program. ; /TOEND: (B) Add this backup set after existing data on the tape. ; /COMPLETE: (T) List all backup sets on the whole tape. ; NEW: (R) Specifies an alternate vol:\path for restored files. ; QUICK: (R) Controls use of QFA (Quick File Access). Default is ON. ; Use QUICK=-1 to disable QFA. NOTE: QUICK=-1 is recommended. ; /PAUSE: (A) Insert a PAUSE statement after the NovaBack command has ; executed, to allow inspection of the results. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; Tape action is initiated. Files may be restored to the hard disk. ; Batch files (\BATCH\*.BAT) are created. Log files may be created. ; RESTRICTIONS: ; A tape must be in the DAT drive, suitable for the intended purpose. ; There must be enough files on the tape to accomodate the purpose. ; PROCEDURE: ; A .BAT file is created in \BATCH to hold the command line to ; execute the desired program. The .BAT file is SPAWNed to run the ; program. ; EXAMPLE: ; To back up .RAY (and .BGS) files for a specific date: ; NOVASTOR,'bkp',tape='eu9520',set=21,/therm,log=2,unit=27,/rewind $ ; ,files='d:\images\save\951015*.*',/toend,/pause ; To restore files from a specific backup set: ; NOVASTOR,'rst',tape='eu9379',set=2,log=2,unit=27,/replace,/sub $ ; ,files='d:\images\save',/rewind,quick=-1 ; SEE ALSO: ; ; MODIFICATION HISTORY: ; Written by: DPSteele, ISAS, November 7, 1995. ;- PRO novastor,program,tape=tape,set=set,after=after,before=before $ ,therm=therm,log=log,unit=unit,last=last,replace=replace $ ,batch=batch,files=files,sub=sub,rewind=rewind,toend=toend $ ,complete=complete,new=new,quick=quick,pause=pause ; Help needed? IF N_PARAMS() EQ 0 THEN BEGIN doc_library,'novastor' RETURN ENDIF ; Ensure we're in the right environment for this routine. @isitdos IF NOT dos THEN BEGIN MESSAGE,'Routine only valid in a DOS environment; aborting',/INFORMATIONAL RETURN ENDIF ; Check input parameters; first, TAPE, LOG, and UNIT, which pertain to ; all programs. ; Check TAPE has exactly 1 element and is a STRING. good_tape=((N_ELEMENTS(tape) EQ 1) AND $ (typeof(tape) EQ 7)) IF good_tape THEN BEGIN tape_len=STRLEN(tape) good_tape=(2 LE tape_len) AND (tape_len LE 6) ENDIF IF NOT good_tape THEN BEGIN MESSAGE,'TAPE must be a scalar string of 2..6 characters' $ ,/INFORMATIONAL RETURN ENDIF ; Check LOG has no more than 1 element, and is either a number or a STRING, ; that evaluates to 0..2. IF N_ELEMENTS(log) EQ 0 THEN log=0 ELSE BEGIN good_log=(N_ELEMENTS(log) EQ 1) good_log=good_log AND ((typeof(log) NE 7) OR $ ((48B LE BYTE(log)) AND (BYTE(log) LE 50B))) IF NOT good_log THEN BEGIN MESSAGE,'If defined, LOG must be a scalar number 0..2' $ ,/INFORMATIONAL RETURN ENDIF ELSE log=ROUND(log+0.) ENDELSE ; Check UNIT has exactly 1 element and is either a number or a STRING, that ; evaluates to 0..31. good_unit=(N_ELEMENTS(unit) EQ 1) IF good_unit THEN good_unit=((typeof(unit) NE 7) OR $ (isnumber(STRING(unit),num) NE 0)) IF N_ELEMENTS(num) EQ 1 THEN unit=num IF good_unit THEN good_unit=((0 LE unit) AND (unit LE 31)) IF NOT good_unit THEN BEGIN HELP,unit MESSAGE,'UNIT must be a scalar number 0..31',/INFORMATIONAL RETURN ENDIF ELSE unit=num ; Now check the parameters specific to the program to be invoked. good_prog=(N_ELEMENTS(program) EQ 1) IF good_prog THEN good_prog=(typeof(program) EQ 7) IF good_prog THEN BEGIN program=STRTRIM(STRUPCASE(program)) com='C:\NOVABK\'+program+' ' CASE program OF 'BKP': BEGIN IF N_ELEMENTS(after) GT 0 THEN $ IF NOT good_date(after,'AFTER') THEN RETURN IF N_ELEMENTS(before) GT 0 THEN $ IF NOT good_date(before,'BEFORE') THEN RETURN IF N_ELEMENTS(batch) GT 0 THEN $ IF NOT ((N_ELEMENTS(batch) EQ 1) AND $ (typeof(batch) EQ 7) AND $ (rfindfile(batch) NE '')) THEN RETURN IF NOT ((N_ELEMENTS(files) EQ 1) AND $ (typeof(files) EQ 7)) THEN RETURN batch_name=STRING(tape,set,'.BAT' $ ,FORMAT='("C:\BATCH\",A,I2.2,A)') IF log GT 0 THEN BEGIN log_name=STRING(tapeinforoot+dd+tape,set,'.blg' $ ,FORMAT='(A,I2.2,A)') com=com+')'+log_name+' {' ENDIF ELSE com=com+' {' IF KEYWORD_SET(rewind) THEN $ IF rewind LT 0 THEN com=com+'-R,' $ ELSE com=com+'R,' IF KEYWORD_SET(toend) THEN com=com+'E,' IF KEYWORD_SET(sub) THEN com=com+'S,' IF N_ELEMENTS(after) EQ 1 THEN com=com+'A:'+after+',' IF N_ELEMENTS(before) EQ 1 THEN com=com+'B:'+before+',' IF KEYWORD_SET(therm) THEN com=com+'X,' IF log GT 0 THEN com=com+'G'+STRTRIM(log,2)+',' com=com+'I=('+STRTRIM(unit,2)+')} ' com=com+files+' ' IF N_ELEMENTS(batch) EQ 1 THEN com=com+'('+batch+')' IF KEYWORD_SET(pause) THEN com=[com,'PAUSE'] FOR i=0,N_ELEMENTS(com)-1 DO PRINT,com(i) mputfile,batch_name,com END 'RST': BEGIN good_set=(N_ELEMENTS(set) EQ 1) IF good_set THEN good_set=((typeof(set) NE 7) OR $ (isnumber(STRING(set),num) NE 0)) IF (N_ELEMENTS(num) EQ 1) THEN set=num IF good_set THEN good_set=(0 LT set) IF NOT good_set THEN BEGIN MESSAGE,'SET must be a scalar number >0',/INFORMATIONAL IF KEYWORD_SET(last) THEN BEGIN MESSAGE,'SET ignored; restore LAST backup set' $ ,/INFORMATIONAL set='LS' ENDIF ELSE RETURN ENDIF ELSE set=STRING(num,FORMAT='(I2.2)') IF N_ELEMENTS(after) GT 0 THEN $ IF NOT good_date(after,'AFTER') THEN RETURN IF N_ELEMENTS(before) GT 0 THEN $ IF NOT good_date(before,'BEFORE') THEN RETURN IF N_ELEMENTS(batch) GT 0 THEN $ IF NOT ((N_ELEMENTS(batch) EQ 1) AND $ (typeof(batch) EQ 7) AND $ (rfindfile(batch) NE '')) THEN RETURN IF NOT ((N_ELEMENTS(files) EQ 1) AND $ (typeof(files) EQ 7)) THEN BEGIN MESSAGE,'Bad files parameter: '+files,/INFORMATIONAL RETURN ENDIF batch_name=STRING(tape,set,'.BAT' $ ,FORMAT='("C:\BATCH\",A,A2,A)') IF log GT 0 THEN BEGIN log_name=STRING(tapeinforoot+dd+tape,set,'.rlg' $ ,FORMAT='(A,A2,A)') com=com+')'+log_name+' {' ENDIF ELSE com=com+' {' IF KEYWORD_SET(rewind) THEN $ IF rewind LT 0 THEN com=com+'-R,' $ ELSE com=com+'R,' IF KEYWORD_SET(sub) THEN com=com+'S,' IF good_set THEN com=com+'F'+set+',' $ ELSE com=com+'Z,' IF N_ELEMENTS(after) EQ 1 THEN com=com+'A:'+after+',' IF N_ELEMENTS(before) EQ 1 THEN com=com+'B:'+before+',' IF log GT 0 THEN com=com+'G'+STRTRIM(log,2)+',' IF KEYWORD_SET(replace) THEN $ IF replace LT 0 THEN com=com+'-X,' $ ELSE com=com+'X,' IF N_ELEMENTS(new) EQ 1 THEN com=com+'N:'+new IF N_ELEMENTS(quick) EQ 1 THEN $ IF quick LT 0 THEN com=com+'-Q,' $ ELSE com=com+'Q,' com=com+'I=('+STRTRIM(unit,2)+')} ' com=com+files+' ' IF N_ELEMENTS(batch) EQ 1 THEN com=com+'('+batch+')' IF KEYWORD_SET(pause) THEN com=[com,'PAUSE'] FOR i=0,N_ELEMENTS(com)-1 DO PRINT,com(i) mputfile,batch_name,com END 'BVER': BEGIN good_set=(N_ELEMENTS(set) EQ 1) IF good_set THEN good_set=((typeof(set) NE 7) OR $ (isnumber(STRING(set),num) NE 0)) IF (N_ELEMENTS(num) EQ 1) THEN set=num IF good_set THEN good_set=(0 LT set) IF NOT good_set THEN BEGIN MESSAGE,'SET must be a scalar number >0',/INFORMATIONAL IF KEYWORD_SET(last) THEN BEGIN MESSAGE,'SET ignored; verify LAST backup set' $ ,/INFORMATIONAL set='LS' ENDIF ELSE RETURN ENDIF ELSE set=STRING(num,FORMAT='(I2.2)') batch_name=STRING(tape,set,'.BAT' $ ,FORMAT='("C:\BATCH\",A,A2,A)') IF log GT 0 THEN BEGIN log_name=STRING(tapeinforoot+dd+tape,set,'.vlg' $ ,FORMAT='(A,A2,A)') com=com+')'+log_name+' {' ENDIF ELSE com=com+' {' IF KEYWORD_SET(rewind) THEN $ IF rewind LT 0 THEN com=com+'-R,' $ ELSE com=com+'R,' IF good_set THEN com=com+'F'+set+',' $ ELSE com=com+'Z,' IF log GT 0 THEN com=com+'G'+STRTRIM(log,2)+',' com=com+'I=('+STRTRIM(unit,2)+')} ' IF KEYWORD_SET(pause) THEN com=[com,'PAUSE'] FOR i=0,N_ELEMENTS(com)-1 DO PRINT,com(i) mputfile,batch_name,com END 'TLST': BEGIN IF KEYWORD_SET(complete) THEN set='AS' ELSE BEGIN good_set=(N_ELEMENTS(set) EQ 1) IF good_set THEN good_set=((typeof(set) NE 7) OR $ (isnumber(STRING(set),num) NE 0)) IF (N_ELEMENTS(num) EQ 1) THEN set=num IF good_set THEN good_set=(0 LT set) IF NOT good_set THEN BEGIN MESSAGE,'SET must be a scalar number >0',/INFORMATIONAL RETURN ENDIF ELSE set=STRING(num,FORMAT='(I2.2)') ENDELSE batch_name=STRING(tape,set,'.BAT' $ ,FORMAT='("C:\BATCH\",A,A2,A)') IF log GT 0 THEN BEGIN log_name=STRING(tapeinforoot+dd+tape,set,'.lst' $ ,FORMAT='(A,A2,A)') com=com+')'+log_name+' {' ENDIF ELSE com=com+' {' IF KEYWORD_SET(complete) THEN com=com+'C,' $ ELSE com=com+'F'+set+',' IF log GT 0 THEN com=com+'L'+STRTRIM(log,2)+',' com=com+'I=('+STRTRIM(unit,2)+')} ' IF KEYWORD_SET(pause) THEN com=[com,'PAUSE'] FOR i=0,N_ELEMENTS(com)-1 DO PRINT,com(i) mputfile,batch_name,com END ELSE: good_prog=0B ENDCASE IF good_prog THEN BEGIN SPAWN,batch_name ENDIF ELSE BEGIN MESSAGE,'Bad program specified: '+program,/INFORMATIONAL RETURN ENDELSE ENDIF RETURN END