Discussions related to exporting backups to tape and backing up directly to tape.
Post Reply
raboese
Novice
Posts: 6
Liked: 1 time
Joined: Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse
Contact:

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

Post by raboese »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
raboese
Novice
Posts: 6
Liked: 1 time
Joined: Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse
Contact:

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

Post by raboese »

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.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
raboese
Novice
Posts: 6
Liked: 1 time
Joined: Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse
Contact:

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

Post by raboese »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
raboese
Novice
Posts: 6
Liked: 1 time
Joined: Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse
Contact:

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

Post by raboese »

Ok thank you.
I'll test it.

regards
Henrik Raböse
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
raboese
Novice
Posts: 6
Liked: 1 time
Joined: Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse
Contact:

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

Post by raboese »

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
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
raboese
Novice
Posts: 6
Liked: 1 time
Joined: Feb 24, 2017 3:03 pm
Full Name: Henrik Raböse
Contact:

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

Post by raboese » 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}
}

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests