*Feature Request* - Check for right tape for tape job

Everything about backing up to tape

*Feature Request* - Check for right tape for tape job

Veeam Logoby raboese » Thu Apr 06, 2017 8:55 am

CaseID: 02110854

Hello,
it would be great if the following option is provided.

Configurable (scheduler) option for the tape job, which checks whether the tape you have inserted can be written to the job.
An interval should also be specified for the test.
As an example, check out at 10 o'clock, every one hour.
If a tape is not inserted, or a wrong tape (NOT EXPIRED), then report by email that a tape has to be inserted.

I have used AMANDA until now - and there was this option, which then reported by email that the correct tape must be inserted.


Best regards
Henrik Raböse
raboese
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby v.Eremin » Thu Apr 06, 2017 4:50 pm

If a tape job starts and finds that no tape is inserted in the drive, an email notification will be sent to administrator. This behaviour is controlled by job notifications settings (Job settings -> Options -> Advanced -> Notify when waiting for tape). Thanks.
v.Eremin
Veeam Software
 
Posts: 13728
Liked: 1027 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby raboese » Fri Apr 07, 2017 6:46 am

This is not my described request.
I will check for the right tape before the tape job will write top tape.


Example:
The tape jab is configured to scheduled run on 8:00 o'clock pm.
There should be an option to configure, that the job begins to check for the right tape on 2:00 o'clock pm.
If a tape is not inserted, or a wrong tape (NOT EXPIRED), then report by email that a tape has to be inserted.
I will not informed for the wrong tape at 8:00 o'clock pm, when the job should run. I will informed for the wrong tape e.g. 4 hours before.
This check should also configurable to check again e.g. in 60 minutes.


This feature is implemented in other backup software. Take a look at AMANDA.
raboese
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby v.Eremin » Fri Apr 07, 2017 9:53 am

If I'm not mistaken, this is the first time when we get this request. For now you can bypass it by writing a simple PowerShell script that will check a tape drive and see whether appropriate tape is inserted.

Thank you for your feedback; appreciated.
v.Eremin
Veeam Software
 
Posts: 13728
Liked: 1027 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby raboese » Wed Apr 19, 2017 9:54 am

Ok, this option sounds good.
But I do not know what to write in the script.
Can you please give me a template for the script, or the commands that I can use to get this query.

Regards
Henrik Raböse
raboese
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby v.Eremin » Sat Apr 22, 2017 10:59 am

I don't have a console at hand, so can only describe potential algorithm for you.

1) Get a tape drive, using Get-VBRTapeDrive cmdlet (VB&R PS)
2) Try to get a tape in this drive, using Get-VBRTapeMedium cmdlet (VB&R PS)
3) If null or wrong media is returned in the step 2, send an email, using Send-MailMessage (Windows PS) cmdlet

Thanks.
v.Eremin
Veeam Software
 
Posts: 13728
Liked: 1027 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby raboese » Mon Apr 24, 2017 7:37 am

Ok thank you.
I'll test it.

regards
Henrik Raböse
raboese
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby v.Eremin » Mon Apr 24, 2017 1:03 pm

Should you need any assistance with scripting, create a topic in the dedicated forum section. And either me or someone less will provide you with required code lines there. Thanks.
v.Eremin
Veeam Software
 
Posts: 13728
Liked: 1027 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby raboese » Thu May 04, 2017 7:21 am

Ok. Thank you for your hints.

I've written some code lines ;) and the script is working very well.

The script call the inventory-routine for the drive, and got the tape name.
But I still have a thought: If the drive is busy, how can I determine this? I do not want to call Inventory, for example: when drive is writing.

Can you give me some routines to detect the status for the drive, e.g. IDLE.


Regards
Henrik Raböse
raboese
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby v.Eremin » Thu May 04, 2017 12:49 pm

Checking whether there are running tape jobs should be enough, I believe. Rough example:

Code: Select all
if ((Get-VBRTapeJob | where {$_.LastState -eq "Running"}) -eq $null)
{
#Inventory drive
}

Thanks.
v.Eremin
Veeam Software
 
Posts: 13728
Liked: 1027 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: *Feature Request* - Check for right tape for tape job

Veeam Logoby raboese » Tue May 09, 2017 1:19 pm 1 person likes this post

For other users...

Code: Select all
$subject           = "Veeam Backup Check failed"
$to                = "address1@dom.tdl" , "address2@dom.tdl"
$from              = "veeam@dom.tdl"
$smtp              = "smtp.dom.tdl"
$tapeLibraryUID    = "8720a44e-fd29-4b2d-b8e1-22034e314761"
$tapeDriveUID      = "c0789ff0-cd7c-4f31-b10f-296ad92a8cfc"
$timoutNextCheck   = 60
$maxFailCounts     = 5


if ( (Get-PSSnapin -Name VeeamPSSnapin -ErrorAction SilentlyContinue) -eq $null ){
   Add-PSSnapin VeeamPSSnapin
}

function lastFriday{
   #monat start
   $date = Get-Date
   $date = Get-Date -year $date.Year -month $date.month -day 1
   
   #ersten freitag suchen
   while( $date.DayOfWeek -ne [DayOfWeek]::Friday ) { $date = $date.AddDays(1) }
   
   #letzten freitag suchen
   while( $date.Month -eq $date.AddDays(7).Month ) { $date = $date.AddDays(7) }
   
   return $date
}

function isLastFriday{
   if( (Get-Date).Day -eq (lastFriday).Day ){
      return 1
   }
   return 0
}

function checkMo{
   $tape = checkTape
   if( $tape -eq "" -or $tape -ne "Tape Montag" ){
      wrongTape $tape "Tape Montag"
   }
}

function checkDi{
   $tape = checkTape
   if( $tape -eq "" -or $tape -ne "Tape Dienstag" ){
      wrongTape $tape "Tape Dienstag"
   }
}

function checkMi{
   $tape = checkTape
   if( $tape -eq "" -or $tape -ne "Tape Mittwoch" ){
      wrongTape $tape "Tape Mittwoch"
   }
   else{
      "OK"
   }
}

function checkDo{
   $tape = checkTape
   if( $tape -eq "" -or $tape -ne "Tape Donnerstag" ){
      wrongTape $tape "Tape Donnerstag"
   }
}

function checkFr{
   $tape = checkTape
   if( $tape -eq "" ){
      echo "wrong tape"
      return
   }
   #welcher freitag?
   if( isLastFriday -eq 1 ) {
      #monatsband suchen
      $mon = (Get-Date).Month
      if( $mon -eq 1 -or $mon -eq 5 -or $mon -eq 9 ){
         $band = "Tape Quartal 1"
      }
      if( $mon -eq 2 -or $mon -eq 6 -or $mon -eq 10 ){
         $band = "Tape Quartal 2"
      }
      if( $mon -eq 3 -or $mon -eq 7 -or $mon -eq 11 ){
         $band = "Tape Quartal 3"
      }
      if( $mon -eq 4 -or $mon -eq 8 -or $mon -eq 12 ){
         $band = "Tape Quartal 4"
      }
   }
   else{
      #freitagsband bestimmen
      $friday = [int][math]::Ceiling( ((Get-Date).Day) / 7 )
      $band = "Tape Freitag $friday"
   }
   if( $band -ne $tape ){
      wrongTape $tape $band
   }
}

function wrongTape( [String] $isTape, [String] $mustTape ){
   $output = "There is the wrong tape inserted: $isTape.`nPlease insert the right tape: $mustTape.`n"
   $output
   Send-MailMessage -to $to -body $output -from $from -smtpserver $smtp -subject "$subject"
   #"Wrong tape: $isTape"
}

function checkTape{
   if( (Get-VBRTapeLibrary -id $tapeLibraryUID | Start-VBRTapeInventory -wait).Result -eq "Success" ){
      #"Inventory OK"
   }
   else{
      #"Inventory failed"
      return "";
   }
   return (Get-VBRTapeMedium -Drive $tapeDriveUID).Name
}


#first check, is tape-drive busy or idle
$failCount = 0
if ((Get-VBRTapeJob | where {$_.LastState -eq "Running"}) -ne $null)
{
   if( $failCount -ge $maxFailCounts ){
      $output = "The tape drive is busy to check for right tape.`nAfter $maxFailCounts try by $timoutNextCheck timeout, given up.`n"
      $output
      Send-MailMessage -to $to -body $output -from $from -smtpserver $smtp -subject "$subject"
      exit
   }
   Start-Sleep -s timoutNextCheck
   $failCount = $failCount +1
}

$dayOfWeek = (Get-Date).DayOfWeek.value__

switch($dayOfWeek){
   1 {checkMo}
   2 {checkDi}
   3 {checkMi}
   4 {checkDo}
   5 {checkFr}
}

raboese
Novice
 
Posts: 6
Liked: 1 time
Joined: Fri Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse


Return to Tape



Who is online

Users browsing this forum: dburton and 1 guest