$! $! BCK_SELECT_FILE.COM $! $! Created: 23-Apr-93 L. Baldwin $! Desc: Command procedure to restore a file from backups $! 24-Apr-93 - V1.0.1 $! 11-Jun-93 - V1.0.2 $ @TASM$COM:TASM_MENUSYM $ @TASM$COM:BCK_SETS ! Get backup set information $! $GET_SET: $ say cls $ i = 1 $SET_LOOP: $ set = f$element(i,"/",bck_sets) $ say "''i' - ''set'" $ i = i + 1 $ if (i .le. bck_numsets) then goto SET_LOOP $! $ inquire/nopun set_num "Select a backup set (1 - ''bck_numsets'): " $ if set_num .eqs. "" then exit $ if (set_num .le. bck_numsets) .and. (set_num .gt. 0) then - goto GET_DISK $ say "Invalid selection." $ goto GET_SET $! $GET_DISK: $ say cls $ bckset = f$element(set_num,"/",bck_sets) $ @TASM$COM:BCK_SETS 'bckset' $ i = 1 $ num_disks = bck_count $DISK_LOOP: $ lognam = f$element(i,"/",bck_devices) $ disknam = f$trnlnm(lognam) $ volnam = f$getdvi(disknam,"VOLNAM") $ say "''i' - ''lognam'- ''volnam' (''disknam')" $ i=i + 1 $ if (i .le. num_disks) then goto DISK_LOOP $ inquire/nopun disk_num "Select disk by number (1 - ''num_disks'): " $ if disk_num .eqs. "" then goto GET_SET $ if (disk_num .le. num_disks) .and. (disk_num .gt. 0) then - goto SEARCH_LIST $ say "Invalid selection." $ goto GET_DISK $! $SEARCH_LIST: $! Search all listing files for the selected disk, convert date to $! yy-mm-dd format (for sorting), then sort $ disk_name = f$element(disk_num,"/",bck_devices) $ saveset = f$element(disk_num,"/",bck_savesets) $ say " " $ say "Searching all ''disk_name' listing files..." $ say " " $! copy backups.dat SYS$SCRATCH:T.TMP $ dir/width=(file=30,display=132) - TASM$BACKUPS:*.LIS/DATE/OUT=SYS$SCRATCH:T.TMP $ search SYS$SCRATCH:T.TMP 'saveset'/out=SYS$SCRATCH:SUBSET.TMP $ if ($status .eq. 1) then goto 10 $ say "No backup listing files found for disk: ''disk_name'." $ goto GET_DISK $10: $ open/read inp SYS$SCRATCH:SUBSET.TMP $ open/write out SYS$SCRATCH:SUBSET.SRT $15: $ read/end=20 inp line $ space = f$locate(" ",line) $ file = f$extract(0,space,line) $ a_date = f$extract(space,f$length(line),line) $ a_date = f$edit(a_date,"TRIM") $ c_date = f$cvtime(a_date,"COMPARISON") $ str = f$fao("!30AS !22AS",file,c_date) $ write out str $ goto 15 $20: $ close inp $ close out $ sort/key=(pos:30,size:22,DESC) sys$scratch:subset.srt sys$scratch:*.srt $ delete sys$scratch:SUBSET.TMP; $! $! Now open sorted list and allow user to select $! $! Read all lines into line[i] $ open/read inp SYS$SCRATCH:SUBSET.SRT $ i = 1 $30: $ read/end=40 inp line'i' $ i=i + 1 $ goto 30 $40: $ num_lines = i $ close inp $! $ TYPE SYS$INPUT The following is a list of backup listing files that exist. They are sorted by date of backup (latest backups listed first). Press "N" for the next page Press "P" for the previous page Press to return to the previous menu $ i = 1 $ a = 0 ! First set of ten $ return_label = "GOT_CHOICE" $DISPLAY_TEN: $ c = i + a $ max_lines = num_lines - a - 1 $ if max_lines .gt. 10 then max_lines = 10 $ tline = line'c' $ str = f$fao("!2UL - !52AS",i,tline) $ say str $ i = i + 1 $ if i .gt. max_lines then goto 45 $goto DISPLAY_TEN $45: $ i = 1 $ say " " $ inquire/nopun choice - "Enter choice # (1-10), P or : " $ if choice .eqs. "" then goto GET_DISK $ ch = f$edit(choice,"UPCASE") $ if ch .eqs. "N" then goto 48 $ if ch .eqs. "P" then goto 47 $ if choice .lt. 0 .or. choice .gt. max_lines then goto 46 $ goto 'return_label' $46: $ say "Invalid choice." $ goto DISPLAY_TEN $47: $ if a .gt. 0 then a = a - 10 $ goto DISPLAY_TEN $! $48: $ if a + 10 .le. num_lines then a = a + 10 $ goto DISPLAY_TEN $! $GOT_CHOICE: $! Now we have a listing file to search. Ask the user $! for a file name. $ choice = choice + a $ selection = line'choice' $ listfile = "TASM$BACKUPS:''f$element(0," ",selection)' $GET_FILE: $ say "Listfile = ''listfile'" $ type sys$input Enter the filename you wish to restore. Enter the filename in the following format: [directory.subdir.]filename.type e.g. [USER.SMITH]LOGIN.COM You may leave out any part of the filename, but the less specific you are the more choices you will have to select from. e.g. LOGIN.COM $ inquire/nopun filename "Enter filename: " $ search 'listfile' "[","''filename'"/MATCH=AND- /output=sys$scratch:listsrch.tmp $ if ($status .eq. 1) then goto 55 $ say "File was not found in listing file." $GET_FCHOICE: $ say "Enter Q - Quit, R - Restart, N - New file" $ inquire/nopun choice "Choice: " $ choice = f$edit(choice,"UPCASE") $ if choice .eqs. "Q" then EXIT $ if choice .eqs. "N" then goto GET_FILE $ if choice .eqs. "R" then goto GET_DISK $ say "Invalid choice." $ goto GET_FCHOICE $55: $! Read all lines into line[i] $ open/read inp SYS$SCRATCH:LISTSRCH.TMP $ i = 1 $60: $ read/end=65 inp line $ line = f$edit(line,"COMPRESS") $ line'i' = line $ i=i + 1 $ goto 60 $65: $ num_lines = i $ close inp $! $ i = 1 $ a = 0 ! First set of ten $ return_label = "GOT_FILE" $ goto DISPLAY_TEN $GOT_FILE: $ choice = choice + a $ sel_file = f$element(0," ",line'choice') $GET_TAPE: $ inquire/nopun tape_device "Tape drive to use [''bck_tape']: " $ if tape_device .eqs. "" then tape_device=bck_tape $! $! Submit job to perform restore $! $! P1 - Tape Label $! P2 - Saveset name $! P3 - Filename $! P4 - Tape device $ tape_label = f$element(0,"_",selection) $ say "label = ''tape_label'" $ say "saveset = ''saveset'" $ say "file = ''sel_file'" $ submit/noprint/notify- /param=("''tape_label'","''saveset'","''sel_file'","''tape_device'") - TASM$COM:BCK_RESTORE_FILE/LOG=TASM$BACKUPS: