Jump to content

TapeRotator.au3


Anteaus
 Share

Recommended Posts

A simple script, but a handy one if you maintain servers.

One of the issues I always encounter is that of onsite staff not understanding tape-backup schemes. You can lecture to them 'til the cows come home, prepare all sorts of fancy diagrams, etc... and still, all you get is blank stares, and the same tape used over again each day.

OK, so one answer might be a tape mag, but they cost serious bucks, and aren't always too reliable. Less costly, a script which tells the operator which tape to insert, based on the date. Operator runs script on own computer. Picks tape with correct label. Inserts into server. Easy.

; Tape Rotator by Anteaus, Oct 2007.
; Released under GPL. 
; Calculates tape required for rotational backup.

; As-supplied, is designed for a Four-Weekday (Mon-Thu), Four-Friday and Twelve-Monthly tape set,
; but should be easy enough to reconfigure for other schemes. 

$bkYear=@year
$bkMonth=@mon
$bkDay=@mday
$wkDay=@wday

; Optionally add cmdline-input here to allow checking of other dates. 

$daysThisMonth=daysinMonth($bkYear,$bkMonth)
$dayNames=stringSplit("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",",")
$MonthNames = stringSplit("January,February,March,April,May,June,July,August,September,October,November,December",",")
$monthName=$monthNames[$bkMonth]
$dayName=$dayNames[$wkDay]

$tapeSet = "N/A"
$tapeName= "No Backup Today"

Select
 case ($wkDay > 1) and ($wkDay < 6)
   $tapeSet="Daily Tapes"
   $tapeName=$dayName
 case $wkDay=6
  if ($daysThisMonth - $bkDay) < 7 then  
   $tapeSet="Month-End Tapes"
   $tapeName=$monthName
  else
   $tapeSet="Week-End Tapes"
   $tapeName=$dayName & " " & tapeOrdinal($bkDay)
  endif
endselect

msgbox(0,"-: Backup Tape Selector :- ", "Tape Set: " & $tapeSet & @cr & @cr & "Tape Name: " & $tapeName,30)

exit

; ----------------------------------------------------------

func TapeOrdinal($bkDay)
  $weekselapsed=$bkDay/7
  $thisOrdinal=int($weeksElapsed) + 1
  $OrdinalNames=stringsplit("One,Two,Three,Four,Five",",")
  $thisOrdinalName=$OrdinalNames[$thisOrdinal]
  return $thisOrdinalName
endfunc

func yDays($thisYear)
 Select
  Case Mod($thisYear,4) = 0 And Mod($thisYear,100) <> 0
   $ctYDays=366
  Case Mod($thisYear, 400) = 0
   $ctYDays=366
  Case Else
   $ctYDays=365
 EndSelect
 return $ctYDays
endfunc

func daysinMonth($thisYear,$thisMonth)
; requires: func yDays()
  Local $xpMDays=stringSplit("31,28,31,30,31,30,31,31,30,31,30,31",",")
  if yDays($thisYear)=366 then $xpMDays[2]=29
  $daysinthisMonth=$xpmDays[$thisMonth]
  return $daysinthisMonth
endfunc

Compatibility: Compile with Aut2EXE 3.2 or higher.

Edited by Anteaus
Link to comment
Share on other sites

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...