Tape Handling with script / script partial working

PowerShell script exchange

Tape Handling with script / script partial working

Veeam Logoby kawiMTF » Wed Feb 24, 2016 8:02 am

Hello folks

First of all i know that there are many posts about Veeam Tape and scripting. I followed some of them and picked out what i needed to create a script that should work.

Well, that's it, it should work. When i execute it manually, the script does what's expected. When it's executed right within the tape job (Options => Advanced => Advanced => Run the following script before the job) it does not work. At least i see that when i check the running backup the next morning, Veeam is waiting for tape. Then i execute the script manually, and poof, the tape goes in the correct media pool and the job uses the inserted tape to write data.

I execute a batch script with the following code in it:
Code: Select all
powershell.exe C:\Library\Scriptlib\pretape.ps1


The batch script fires up Powershell and then this code will be executed:
Code: Select all
Add-PSSnapin VeeamPSSnapin
Get-VBRTapeDrive -Name "Tape0" | Start-VBRTapeInventory
$tape = Get-VBRTapeMedium
Move-VBRTapeMedium -Medium $tape -MediaPool "TapePool" -Confirm:$false


This script is perhaps not the best one, but at least it works when executed manually. What i have to check is the media stuff. With every execution of this script the powershell output list will be longer and tells me that this and that tape is already in the specific media pool.

I have also to find out why it's not executed at the job runtime. I now created a task in Windows task scheduler and will see tomorrow if that works.

My customer has about 20 tapes. For each weekday a tape and this for about four weeks (monday 1, monday 2 and so on). When we switched from Backup Exec to Veeam i had similar issues. But then i deleted all the tapes with HP Library & Tape tools, and Veeam took every tape without any issue or scripting.

Now the tapes are once rotated completely and now Veeam does not accept the tapes without manual handling or automated via script.

Does any one of you have an idea why the script is not executed at job runtime? And how can this script be improved?

Thank you very much!
Best regards,
Karl

-----------------------
Veeam Platinum Partner
Veeam Vanguard / VMCE v9 / VMTSP v9 / VMSP v9
vExpert / VCA6-DVC / VCA5-DVC / VCA5-Cloud
MCP / MCSA 2012
Personal blog: https://www.driftar.ch
Twitter: @widmerkarl
kawiMTF
Veeam Vanguard
 
Posts: 116
Liked: 20 times
Joined: Tue Jan 06, 2015 10:03 am
Location: Switzerland
Full Name: Karl Widmer

Re: Tape Handling with script / script partial working

Veeam Logoby foggy » Wed Feb 24, 2016 8:40 am

Karl, please review this thread for possible reasons of why the script doesn't run.
foggy
Veeam Software
 
Posts: 14716
Liked: 1075 times
Joined: Mon Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson

Re: Tape Handling with script / script partial working

Veeam Logoby kawiMTF » Wed Feb 24, 2016 9:31 am

Hello foggy,

Thanks for the input. Indeed i did some checks which i saw in the thread you mentioned (permissions etc.).

- Veeam services are configured to run with user account "domain\administrator"
- I can't add the domain administrator to local administrator group since the veeam backup server is a second domain controller
- I checked the Veeam logs and can find entries that the script has been executed successfully:

Code: Select all
[22.02.2016 10:06:57] <01> Info     Running pre-job script
[22.02.2016 10:06:57] <01> Info     Executing custom command 'C:\Library\Scriptlib\pretape.cmd', arguments ''
[22.02.2016 10:07:01] <01> Info     Pre-job script completed successfully


But as i mentioned Veeam goes in the state "waiting tape" until i execute the script manually.

As i wrote above i added a task now in Windows task scheduler and will come back tomorrow with an update.
Best regards,
Karl

-----------------------
Veeam Platinum Partner
Veeam Vanguard / VMCE v9 / VMTSP v9 / VMSP v9
vExpert / VCA6-DVC / VCA5-DVC / VCA5-Cloud
MCP / MCSA 2012
Personal blog: https://www.driftar.ch
Twitter: @widmerkarl
kawiMTF
Veeam Vanguard
 
Posts: 116
Liked: 20 times
Joined: Tue Jan 06, 2015 10:03 am
Location: Switzerland
Full Name: Karl Widmer

Re: Tape Handling with script / script partial working

Veeam Logoby kawiMTF » Tue Apr 12, 2016 10:07 am

Hello everyone

Long time ago since i had this issue. And i don't really like to dig out old threads. But today we found a possible solution and i think that this hint will perhaps help someone.

Code: Select all
Add-PSSnapin VeeamPSSnapin
Get-VBRTapeDrive -Name "Tape0" | Start-VBRTapeInventory -Wait
$tape = Get-VBRTapeMedium -Drive "Tape0"
Erase-VBRTapeMedium -Medium $tape -Wait
Move-VBRTapeMedium -Medium $tape -MediaPool "Free" -Confirm:$false


The script above does the following:

1) it loads the Veeam powershell snappin.
2) it gets the tape drive "tape0" and does an inventory. It waits for the next steps until inventory is done.
3) It writes the content of the tape drive (literarily the name of the tape) in the variable "$tape".
4) the script then erases the tape with the variable "$tape" (quick erase) and waits until this step is done.
5) the script then moves the tape to the Veeam media pool "Free".

You will have to check the settings within the manually created media pool, that the media pool adds free tapes automatically from the free media pool in case, additional capazity is needed.
Best regards,
Karl

-----------------------
Veeam Platinum Partner
Veeam Vanguard / VMCE v9 / VMTSP v9 / VMSP v9
vExpert / VCA6-DVC / VCA5-DVC / VCA5-Cloud
MCP / MCSA 2012
Personal blog: https://www.driftar.ch
Twitter: @widmerkarl
kawiMTF
Veeam Vanguard
 
Posts: 116
Liked: 20 times
Joined: Tue Jan 06, 2015 10:03 am
Location: Switzerland
Full Name: Karl Widmer

Re: Tape Handling with script / script partial working

Veeam Logoby v.Eremin » Tue Apr 12, 2016 10:41 am

Is the last line really necessary? The erased tape should be automatically placed in free media pool, if remember that correctly. Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 966 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Tape Handling with script / script partial working

Veeam Logoby kawiMTF » Tue Apr 12, 2016 5:49 pm

Hi Vladminir,

We tested it without it, but then nothing happend. After running the script there was just a empty tape in the drive.

Of course the tape we tested was member of an existing media pool. So it stayed there empty in this specific media pool, until we added the last line.

We will test it the next few days. Perhaps the last line can be removed, when the tape IS member of an existing media pool, but leave the line if the tape is NOT a member of an existing media pool.
Best regards,
Karl

-----------------------
Veeam Platinum Partner
Veeam Vanguard / VMCE v9 / VMTSP v9 / VMSP v9
vExpert / VCA6-DVC / VCA5-DVC / VCA5-Cloud
MCP / MCSA 2012
Personal blog: https://www.driftar.ch
Twitter: @widmerkarl
kawiMTF
Veeam Vanguard
 
Posts: 116
Liked: 20 times
Joined: Tue Jan 06, 2015 10:03 am
Location: Switzerland
Full Name: Karl Widmer

Re: Tape Handling with script / script partial working

Veeam Logoby v.Eremin » Wed Apr 13, 2016 1:34 pm

We tested it without it, but then nothing happend. After running the script there was just a empty tape in the drive.

After having thought about it for a little while, I can confirm that the last line is indeed necessary. A tape that used to belong to some media pool, not including pre-defined ones, will stay in this media pool after erase operation.

Thus, keep the last line as is.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 966 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