$! BCK_CALC_LABEL.COM $! $! Determine which tape label we need to use $! $! Note: If anything is passed in P3 then we generate a complete $! backup schedule for the entire month $! $! Parameters: $! $! P1[required] - Backup set $! P2[required] - Scheduled backup date $! P3[optional] - "Y" generate and print schedule $! "N" just to generate schedule $! $! $! $! Constants: $ days_of_week="SunMonTueWedThuFriSat" $! $ ON WARNING THEN GOTO PROCESS_ERROR $ @TASM$COM:TASM_MENUSYM ! Get global symbols $! $ bckset = p1 $ label == p1 ! First part of label = bckset $ date = p2 $ gen_sched = p3 $ run_date = date $ if run_date .eqs. "CURRENT" then run_date = "" $ if gen_sched .nes. "" then goto CREATE_SCHED $! Unless we're generating a full schedule, just call DO_CALC once $! and then exit $ gosub DO_CALC $ goto DONE $! $CREATE_SCHED: $! $ @TASM$COM:BCK_SETS 'bckset' $ month = f$cvtime(run_date,"ABSOLUTE","MONTH") $ year = f$cvtime(run_date,"ABSOLUTE","YEAR") $ first_day = "01-"+month+"-"+year $ count = 0 ! start on the 1st of the month $ say :=write out $ open/write out TASM$SCRATCH:BCK_SCHED_'bckset'.RPT $ say " Schedule for ''month' ''year'" $ say " Backup Set: ''bckset'" $ say "" $! set nover $SCHED_LOOP: $ date = first_day+"+''count'-" ! Delta date format +count days $ date = f$cvtime(date,"ABSOLUTE","DATE") ! Convert to real date $ weekday = f$cvtime(date,"ABSOLUTE","WEEKDAY") $ day = f$cvtime(date,,"DAY") $! See if we've gotten to the next month yet? $ if (count .gt. 0) .and. day .eqs. "01" then goto SCHED_DONE $ str = "" $ count = count + 1 $ gosub DO_CALC $ if label .nes. "" then str = str + label+"," $ if str .nes. "" then - str = f$extract(0,f$length(str)-1,str) !truncate last char. $ tmp = f$fao("!/!10AS, !11AS: !40AS",weekday,date,str) $ say tmp $ label == p1 ! Reset label for next run $ goto SCHED_LOOP $SCHED_DONE: $ close out $ if p3 .eqs. "Y" then print TASM$SCRATCH:BCK_SCHED_'bckset'.RPT $ goto DONE $! $! Subroutine DO_CALC $! $DO_CALC: $ month = f$cvtime(date,"ABSOLUTE","MONTH") ! e.g. Jan, Feb, etc. $ month_cmp - ! e.g. 01, 02, etc. = f$integer(f$cvtime(date,"COMPARISON","MONTH")) $ day = f$integer(f$cvtime(date,,"DAY")) ! e.g. 01 - 31 $ year = f$cvtime(date,,"YEAR") ! e.g. 1993, 1994, etc. $ weekday = f$extract(0,3,f$cvtime(date,,"WEEKDAY")) ! e.g. Mon, Tue, ... $! $! Calculate week number within month (e.g. Week 1, Week 2, etc..) $! $ first_dayname = f$cvtime("01-''month'-''year'",,"WEEKDAY") $ first_dayname = f$extract(0,3,first_dayname) $ first_daynum = f$locate(first_dayname, days_of_week)/3 $ week_num = (day + first_daynum + 6)/7 $! $! Since yearly, monthly, and weekly are all done $! on the weekly day, then if it is not that day we $! know that this is just a daily backup. $ weekly = (bck_weekly .eqs. weekday) $ if .not. weekly then GOTO DAILY_BACKUP $! $! Is it a yearly $! $YEARLY_BACKUP: $! See if this is the proper month and week to perform a yearly backup $ if (month_cmp .ne. bck_yearly) .or. - (bck_monthly .nes. week_num) then GOTO MONTHLY_BACKUP $! $! Alternate yearly label Y2 for even years, Y1 for odd years $ odd = year - ((year*2)/2) $ if odd then label == label + "Y1" $ if .not. odd then label == label + "Y2" $ RETURN $! $! Or is it a monthly backup $! $MONTHLY_BACKUP: $ if bck_monthly .nes. week_num then GOTO WEEKLY_BACKUP $! $! Set label to M01, M02, M03, etc. $! $ label == label + "M" + f$string( month_cmp ) $ RETURN $! $! Is it a weekly backup $! $WEEKLY_BACKUP: $! $ label == label + "W" + f$string(week_num) $ RETURN $! $! Determine if daily scheduled for this day $! $DAILY_BACKUP: $ position = f$locate(weekday,bck_daily) $ if position .ge. f$length(bck_daily) then goto 34$ $! Convert weekday (Sun, Mon, etc.) to value (1,2,3, etc.) $ day_value = f$locate(weekday,days_of_week)/3 + 1 $! $! Calculate unique day number within month (1 - 37) $! $ label == label + "D" + f$string(day_value + ((week_num - 1) *7)) $ RETURN $ 34$: $! say "There are not backups scheduled for this the" $! say "specified disk on this day." $ label == "" $ RETURN $! $! Modification History: $! 17-Sep-91 llb - add schedule for ARCHIVE logs $! 11-Jun-93 llb - Add more error handling $DONE: $ EXIT $! $PROCESS_ERROR: $ saved_sts = $STATUS $ say "An Error occurred in BCK_CALC_LABEL" $ exit saved_sts ! Exit and return status