Erase any tape that is inserted

PowerShell script exchange

Erase any tape that is inserted

Veeam Logoby dvdv » Thu Jan 29, 2015 9:15 am

Hi,

I've been playing around with the following, but for some reason it doesn't work reliable.

Situation:
I want to perform a backup 2 disk (forever incremental) and when it's finished, it needs to be written to tape immediately.
The jobs themselves are configured in the correct manner and when the first one is done, the tape job kicks in nicely.

I have a script that runs at 6pm every day, and it should quick erase any tape that is inserted in the drive, so it can be used for the tapejob later that evening.
Script:
-----------------------------------------
Write-host “Prepare Tape for Veeam backup”
Add-PSSnapin -Name VeeamPSSnapin
Get-VBRTapeMedium | where {$_.location -like "Drive"} | Erase-VBRTapeMedium -confirm:$false
----------------------------------------
It seemed to have worked for a while, but yesterday and today the task scheduler reports that the job runned fine, but the tape is not erased.
As a result the data is added to the tape and it asks for another tape.

Could someone have a look at my script and tell me where to improve it?

Thanks!

Regards,

Dennis
dvdv
Novice
 
Posts: 4
Liked: 1 time
Joined: Thu Jan 29, 2015 9:03 am
Full Name: Dennis

Re: Erase any tape that is inserted

Veeam Logoby v.Eremin » Thu Jan 29, 2015 2:32 pm

The script itself looks good. Will it work if you start it manually? Thanks.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Erase any tape that is inserted

Veeam Logoby dvdv » Thu Jan 29, 2015 3:17 pm

Yes, when I started it manually all works fine.

I also re-scheduled it and let it run while I was watching, and (ofcourse...) it also ran fine again. ;-)
The tapes I'm using aren't new ones.
As a test I've tried to manually erase one of the tapes that 'didn't work', and guess what....once again no problem.

So I'm a bit confused now.....all things seems to be ok, they all work fine when done manually, but for some reason it just didn't work 2 times in a row.

Any suggestions?
dvdv
Novice
 
Posts: 4
Liked: 1 time
Joined: Thu Jan 29, 2015 9:03 am
Full Name: Dennis

Re: Erase any tape that is inserted

Veeam Logoby v.Eremin » Thu Jan 29, 2015 3:24 pm

For me it sounds like problem lies outside of Veeam, as script does it job perfectly, if executed manually. I would double check accounts under which script is executed (manually, Scheduler), whether they are the same or have same permissions, etc. Thanks.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Erase any tape that is inserted

Veeam Logoby dvdv » Fri Jan 30, 2015 10:46 am

Ok, thanks for your reply.
Just wanted to check if the script was fine.
I'll investigate further.

Thanks!
dvdv
Novice
 
Posts: 4
Liked: 1 time
Joined: Thu Jan 29, 2015 9:03 am
Full Name: Dennis

Re: Erase any tape that is inserted

Veeam Logoby v.Eremin » Fri Jan 30, 2015 10:54 am

As long as manual execution of script doesn't produce any issues, you can be sure that there is nothing wrong with the code itself. Thanks.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Erase any tape that is inserted

Veeam Logoby dvdv » Mon Feb 02, 2015 9:48 am 1 person likes this post

'problem' found.

When you insert a tape and do not perform an inventory first, the script won't run, since the drive/Veeam doesn't know there is a tape inserted.
To solve it I added a line to perform an inventory first.
Now it's working perfectly.
dvdv
Novice
 
Posts: 4
Liked: 1 time
Joined: Thu Jan 29, 2015 9:03 am
Full Name: Dennis

Re: Erase any tape that is inserted

Veeam Logoby v.Eremin » Mon Feb 02, 2015 10:50 am

Yep, having "Start-VBRTapeInventory -Library <>" line in the beginning of the script should do the trick, indeed. Glad to hear you've nailed it.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests