Erase all online Tapes before a Backup

PowerShell script exchange

Erase all online Tapes before a Backup

Veeam Logoby jmeske » Fri Feb 06, 2015 9:21 am

Hallo and Greetings from Hamburg, Germany

i would like to introduce myself. I am new to VEEAM, but my company is working with veeam several years now.
I would like to improve my knowledge step by step and get a better picture about the tape librarys we support.

Since V7 we had to create a sheduled task within Windows to do an automatically erase job before we start a tape backup job.

We used the Erase-VBRTapeMedium with a parameter online to do the job. Since V8 this parameter is gone.
We solved it for now by this sequence:

Code: Select all
#VEEAM8.0
ASNP VeeamPSSnapin
Get-VBRTapeLibrary | Start-VBRTapeInventory -wait

#Erase Tapes
$tape = get-VBRTapeMedium
write-host $tape
Erase-VBRTapeMedium -Medium $tape -Wait -Confirm:$false


#VEEAM 7.0

#ASNP VeeamPSSnapin
#Get-VBRTapeLibrary -name "TANDBERG StorageLoader 0495"|Start-VBRTapeInventory
#Get-VBRTapeMedium -Unrecognized | Erase-VBRTapeMedium -RunAsync -Confirm:$false
#$Targetpool = get-VBRTapeMediaPool -name "Media Pool 1"
#$tape = get-VBRTapeMedium -online
#IF(($tape|select Mediapoolid) -ne ($Targetpool|select MediaPoolId)){
#    $tape = Get-VBRTapeMedium -Online
#    Move-VBRTapeMedium -Medium $tape -MediaPool $Targetpool -Confirm:$false}


in V8 we could now filter the "Online" Tapes. So the script runs for all tapes.

I would like to find a Solution. to solve this in a better way.

Has anybody solved this so far?

greetings from Hamburg, germany
Jens
jmeske
Novice
 
Posts: 6
Liked: 1 time
Joined: Mon Jan 26, 2015 1:40 pm
Full Name: Jens Meske

Re: Erase all online Tapes before a Backup

Veeam Logoby v.Eremin » Fri Feb 06, 2015 9:51 am

I believe the offline mediums can be gotten via the following script:

Code: Select all
Get-VBRTapeMedium | where {$_.Location.Type -eq "offline"}

Is that what you're looking for?

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

Re: Erase all online Tapes before a Backup

Veeam Logoby jmeske » Fri Feb 06, 2015 10:34 am

Hallo v.Eremin,

yes its seems so, thank you.
I tried, but the $tape String is always empty, no matter if i use online or offline.

#VEEAM8.0
ASNP VeeamPSSnapin
Get-VBRTapeLibrary | Start-VBRTapeInventory -wait



write-host "test"
write-host get-VBRTapeMedium | where {$_.Location.Type -eq "online"}
write-host $tape "test2"

Any Idea?
thank you
Jens
jmeske
Novice
 
Posts: 6
Liked: 1 time
Joined: Mon Jan 26, 2015 1:40 pm
Full Name: Jens Meske

Re: Erase all online Tapes before a Backup

Veeam Logoby v.Eremin » Fri Feb 06, 2015 11:16 am

If my memory serves me well there are three types of location, namely offline, slot, drive. So, if the provided code returns nothing, it seems there are no offline mediums. You can try to get all online mediums, using the following script:

Code: Select all
Get-VBRTapeMedium | where {$_.Location.Type -ne "offline"}


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

Re: Erase all online Tapes before a Backup

Veeam Logoby jmeske » Fri Feb 06, 2015 1:55 pm

Hi Erimim,

your answer open my eyes. I tried to test the given responses for location and the library know:
none, drive and slot

So this is now working.
| where {$_.Location.Type -ne "None"}
thank you
and have a nice weekend.
Jens

Code: Select all
#VEEAM8.0
ASNP VeeamPSSnapin
Get-VBRTapeLibrary | Start-VBRTapeInventory -wait

#die aktuellen Bänder löschen
$tape = get-VBRTapeMedium | where {$_.Location.Type -ne "None"}
write-host $tape
Erase-VBRTapeMedium -Medium $tape -Wait -Confirm:$false
jmeske
Novice
 
Posts: 6
Liked: 1 time
Joined: Mon Jan 26, 2015 1:40 pm
Full Name: Jens Meske

Re: Erase all online Tapes before a Backup

Veeam Logoby v.Eremin » Fri Feb 06, 2015 2:14 pm

You're welcome. Don't hesitate to ask for additional clarification, if required.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Erase all online Tapes before a Backup

Veeam Logoby doalwa » Thu Feb 26, 2015 9:42 am 1 person likes this post

Hey Jens,

greetings to a fellow german Veeam user :D

Thanks a lot for your script, I was facing the same problem and can happily report that backups to tape using Veeam v8 are finally working as required for us.
doalwa
Novice
 
Posts: 4
Liked: 1 time
Joined: Thu Feb 26, 2015 9:34 am
Full Name: Dominik Wagner

Re: Erase all online Tapes before a Backup

Veeam Logoby jmeske » Mon Mar 02, 2015 4:00 pm

Dear Doalwa,

thank you for your feedback, it´s nice to hear that this helps someone else.
Greetings from Hamburg, Germany
jmeske
Novice
 
Posts: 6
Liked: 1 time
Joined: Mon Jan 26, 2015 1:40 pm
Full Name: Jens Meske


Return to PowerShell



Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests