List Tapes useb by job

PowerShell script exchange

List Tapes useb by job

Veeam Logoby tcse10 » Wed Feb 04, 2015 11:50 am

Hi there,
we are using B&R v8 and like to generate and print a report about the tapes used by a specific backup to tape job.
I think the best way to do this is to run a powershell script aft the tape job. I found a script for V7 at thins post powershell-f26/tape-job-results-t21184.html and I am trying to port it to v8, but I am enabled to find a way getting the used tapes out of the VBRSession.
This is what I goat till now:
Code: Select all
 asnp "VeeamPSSnapIn"
    $job=get-vbrtapejob -name "Test"
    $session= Get-VBRSession -Job $job -Last
    $session
     [xml]$xml=$session.AuxData
    $session1=$xml.TapeAuxData.TapeMediums.TapeMedium.name
    $session1
    $session2 =Get-VBRTapeMedium -name $session1 |  Select-Object -Property @{N="Barcode";E={$_.Barcode}}, @{N="Location";E={$_.Locationex}}, @{N="Free capacitye";E={$_.Free}} | fl | out-string;
    $session2

can anyone help?
tcse10
Novice
 
Posts: 8
Liked: never
Joined: Wed Feb 04, 2015 10:32 am

Re: List Tapes useb by job

Veeam Logoby v.Eremin » Wed Feb 04, 2015 2:04 pm

I'm wondering whether you want to create a report about tapes used during the latest Job session or report about VM restore points (files) and tapes they reside on? Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List Tapes useb by job

Veeam Logoby tcse10 » Wed Feb 04, 2015 2:20 pm

I like to report about tapes used during the latest Job session. But maybe, I will include the backed up VM restore point in future.
tcse10
Novice
 
Posts: 8
Liked: never
Joined: Wed Feb 04, 2015 10:32 am

Re: List Tapes useb by job

Veeam Logoby v.Eremin » Wed Feb 04, 2015 2:54 pm

Now in order to achieve your goal you have to use more or less unsupported workaround. The rest of the referenced script can stay intact:

Code: Select all
$BTJ = Get-VBRTapeJob -Name "Name of your backup Job"
$Session = [veeam.backup.core.cbackupsession]::GetByJob($BTJ.id) | Sort CreationTime -Descending | select -First 1


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

Re: List Tapes useb by job

Veeam Logoby tcse10 » Wed Feb 04, 2015 3:22 pm

Ok, This is working, but I got the next problem:
The Locationex property of the VBRTapeMedium seems to be removed, and Location only contains Slot (without number) or Drive.
Is there also a workaround? Or is it a configuration issue?
tcse10
Novice
 
Posts: 8
Liked: never
Joined: Wed Feb 04, 2015 10:32 am

Re: List Tapes useb by job

Veeam Logoby v.Eremin » Wed Feb 04, 2015 4:50 pm

In fact, location has a lot of useful information, including slot and drive address (see below).

Image

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

Re: List Tapes useb by job

Veeam Logoby tcse10 » Mon Feb 23, 2015 2:56 pm

I got my script working now, but I wood like to add a list of the latest restore points in the tape job wit its corresponding vms. I can’t find a way to do this in a simple manner. Do you have any suggestions to do this?

In case someone is interested in it, this is my script:
Code: Select all
param(
    [string]$jobName
    )

asnp "VeeamPSSnapIn"
    $Page = "
______            _                 ______                      _   
| ___ \          | |                | ___ \                    | | 
| |_/ / __ _  ___| | ___   _ _ __   | |_/ /___ _ __   ___  _ __| |_
| ___ \/ _`  |/ __| |/ / | | | '_ \  |    // _ \ '_ \ / _ \| '__| __|
| |_/ / (_| | (__|   <| |_| | |_) | | |\ \  __/ |_) | (_) | |  | |_
\____/ \__,_|\___|_|\_\\__,_| .__/  \_| \_\___| .__/ \___/|_|   \__|
                            | |               | |                   
                            |_|               |_|                   
"
$lineHZ="___________________________________________________________________________________"
   
    $job=get-vbrtapejob -name $jobName
    $Session = [veeam.backup.core.cbackupsession]::GetByJob($job.id) | Sort CreationTime -Descending | select -First 1
   
    $PageJob  = "
    Job title:  " + $jobName + "
    Start time: " + $session.CreationTime + "
    End time:   " + $session.EndTime + "
    Result:     " + $session.Result + "
    State:      " + $session.State + "
"
    $Page += $lineHZ + $PageJob + $lineHZ + "

Tapes used by this Job:
"

     [xml]$xml=$session.AuxData
    $session1=$xml.TapeAuxData.TapeMediums.TapeMedium.name
    $session2 =Get-VBRTapeMedium -name $session1 |  Select-Object -Property @{N="Barcode";E={$_.Barcode}}, @{N="Location";E={($_.Location.SlotAddress + $_.Location.Type)}}, @{N="Free capacity (GB)";E={($_.Free/1024/1024/1024)}} | Format-Table -AutoSize | out-string;
    $Page += $session2

 
    $Page += "

                                                                      End of report"

    $Page | Out-Printer
tcse10
Novice
 
Posts: 8
Liked: never
Joined: Wed Feb 04, 2015 10:32 am

Re: List Tapes useb by job

Veeam Logoby v.Eremin » Tue Feb 24, 2015 12:11 pm

I've created previously a script that shows tape content. Is that something you're looking for? Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: List Tapes useb by job

Veeam Logoby tcse10 » Mon Mar 02, 2015 3:02 pm

Inspired by your code I have created this. Maybe it's not a perfect solution but as far as i can tell it works.
Code: Select all
$TapeBackups = Get-VBRTapeBackup | where {$_.getJob().Name -eq $jobName}
$vms = $TapeBackups.GetLastOibs() | select name, CreationTime | Format-Table -AutoSize | Out-String

Maybes someone can find a way to relate to the session and without using the obsolete Get-VBRTapeBackup
tcse10
Novice
 
Posts: 8
Liked: never
Joined: Wed Feb 04, 2015 10:32 am

Re: List Tapes useb by job

Veeam Logoby antspants77 » Wed Feb 03, 2016 2:19 am

Hi,
Sorry that this is an old thread and that GET-VBRTAPEBACKUP cmdlet is even more "obsolete and no loner supported"
However, your scripts seem to be exactly what I was looking for.

Environment.
Veeam 8.0.0.2084
4 x Hyper-v 2008 R2 Sp1
About 20Tbs of data across about 30 VMs
8 disk backup jobs every night.
2 tape dupe jobs to put these on tape each week.
About 20 tapes used each week across these 2 tape jobs.
Backing up to a HP MSL8096 Loader/Tape drive (2 drives, 96 slots)

Requirement.
To provide the customer with a list of tapes and their corresponding tapes to remove each week.

Current process
Open Tape job reports
Copy "Used tapes" into excel.
Then using replace to remove duplicate tape entries (Tape names are listed twice for each tape)
Using the comma as a delimiter to put the tapes into separate columns.
Paste special and use transpose to place all tapes into a single column.
Repeat for 2nd tape job.

Been looking at Vaults, Veeam One etc do not seem to provide what I need. (Take these tapes out and send them offsite)
Veeam One breaks it down by disk jobs within the Tape job. Even if it did, hard to sell them a product, just so they can be told what tapes they can take out like it did Commvault apparently.

As you will probably work out, I know very little about powershell.

Ran the above scripts by.
1. Open Veeam Backup & Replication Console.
2. From Veeam Menu, selected "Powershell"
3. Tried just pasting scripts and running, with a few carriage returns.
4. Tried creating a PS1 file and running that as well. E.g. .\tapeout.ps1

Tried with original script, but changing "test" to name of my tape job "VeeamBackups1 Tape Dupe"

Code: Select all
asnp "VeeamPSSnapIn"
    $job=get-vbrtapejob -name "VeeamBackups1 Tape Dupe"
    $session= Get-VBRSession -Job $job -Last
    $session
     [xml]$xml=$session.AuxData
    $session1=$xml.TapeAuxData.TapeMediums.TapeMedium.name
    $session1
    $session2 =Get-VBRTapeMedium -name $session1 |  Select-Object -Property @{N="Barcode";E={$_.Barcode}}, @{N="Location";E={$_.Locationex}}, @{N="Free capacitye";E={$_.Free}} | fl | out-string;
    $session2


I get the error

Code: Select all
Get-VBRTapeMedium : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument
that is not null or empty, and then try the command again.
At C:\temp\tapeout.ps1:8 char:40
+     $session2 =Get-VBRTapeMedium -name $session1 |  Select-Object -Property @{N= ...
+                                        ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-VBRTapeMedium], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.GetVBRTapeMedium


When I run

Code: Select all
$TapeBackups = Get-VBRTapeBackup | where {$_.getJob().Name -eq $jobName}
$vms = $TapeBackups.GetLastOibs() | select name, CreationTime | Format-Table -AutoSize | Out-String


I get the error

Code: Select all
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $vms = $TapeBackups.GetLastOibs() | select name, CreationTime | Format-Table -Au ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

As this is not supported any more and no other replacement can be found, I'm not sure if I should place a support call.
But let me know and I will

I also looked at v.Eremin script, but was unsure how to combine the original script and his addition.

So, if anyone could please supply me with a method, so that a single script can be run (from the desktop if possible) that just give me a list of tapes that the customer needs to take out.
antspants77
Influencer
 
Posts: 20
Liked: 5 times
Joined: Wed Mar 16, 2011 3:15 pm
Full Name: Tony Spencer

[MERGED] : List tapes, media set and retention

Veeam Logoby nickl99 » Tue Sep 20, 2016 2:58 am

Hi Guys, I have 3 tape jobs that run on sunday and finish on Monday. I'd like a simple report listing tapes used and their retention time so our tape recall company can manage tape records themselves. Is powershell the best way to do this?

I am a newb at powershell, but willing to learn and tinker until correct. I could have a script that runs after each job, and writes to a csv? Or one script that runs after the last tape job and goes through each tape job, lists the tapes used and their expiry\retention. I only really need tape barcode and retention , but any other useful info would be cool.

Thanks!
nickl99
Enthusiast
 
Posts: 26
Liked: 2 times
Joined: Wed Aug 03, 2016 5:09 am
Full Name: NICK LAING

Re: List Tapes useb by job

Veeam Logoby v.Eremin » Tue Sep 20, 2016 10:49 am

Take a look at the script provided above and see whether it asks your requirements. If you're after simpler, say retrieving tapes written within last 24 hours, then, check this thread. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 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 3 guests