PowerShell script exchange
Post Reply
jmeske
Novice
Posts: 6
Liked: 1 time
Joined: Jan 26, 2015 1:40 pm
Full Name: Jens Meske
Contact:

Erase all online Tapes before a Backup

Post by jmeske »

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

veremin
Product Manager
Posts: 17745
Liked: 1615 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Erase all online Tapes before a Backup

Post by veremin »

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.

jmeske
Novice
Posts: 6
Liked: 1 time
Joined: Jan 26, 2015 1:40 pm
Full Name: Jens Meske
Contact:

Re: Erase all online Tapes before a Backup

Post by jmeske »

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

veremin
Product Manager
Posts: 17745
Liked: 1615 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Erase all online Tapes before a Backup

Post by veremin »

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.

jmeske
Novice
Posts: 6
Liked: 1 time
Joined: Jan 26, 2015 1:40 pm
Full Name: Jens Meske
Contact:

Re: Erase all online Tapes before a Backup

Post by jmeske »

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

veremin
Product Manager
Posts: 17745
Liked: 1615 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Erase all online Tapes before a Backup

Post by veremin »

You're welcome. Don't hesitate to ask for additional clarification, if required.

doalwa
Novice
Posts: 6
Liked: 1 time
Joined: Feb 26, 2015 9:34 am
Full Name: Dominik Wagner
Contact:

Re: Erase all online Tapes before a Backup

Post by doalwa » 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.

jmeske
Novice
Posts: 6
Liked: 1 time
Joined: Jan 26, 2015 1:40 pm
Full Name: Jens Meske
Contact:

Re: Erase all online Tapes before a Backup

Post by jmeske »

Dear Doalwa,

thank you for your feedback, it´s nice to hear that this helps someone else.
Greetings from Hamburg, Germany

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests