Discussions related to exporting backups to tape and backing up directly to tape.
Post Reply
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Logging manual tape changes

Post by pshute »

Is there a way to get Veeam to log which tape is in the drive at a particular time of day?

We have a single manual tape drive, and I want to check if people are changing the tape in between weekly backups. E.g. On Tuesday someone might put in the correct tape for the following Monday's backup, but someone, for some reason, manually ejects it and puts in a different one on Thursday. Is there any record kept of that change, and if not, is there a way to get it to make one?

If I run an inventory on the drive, it will display which tape is loaded, but it doesn't list that tape name in the job history. Even if it did, is there a way to schedule an inventory?
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Logging manual tape changes

Post by PTide »

Hi,

You can use PowerShell cmdlets to check what tape is in the drive:

Code: Select all

Get-VBRTapeMedium -Drive (Get-VBRTapeDrive -name "Name of your drive")
That will return you information about current tape. Is that what you need?

Thank you.
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Re: Logging manual tape changes

Post by pshute »

Thanks, that will be very useful.

We only have one tape drive. Is it correct that we can omit the -name parameter?

Initially, the command returned no results. I suspect this was because Veeam thought the drive was empty because I just manually changed the tape this morning. It returned results after an inventory, so it looks like my script will have to do an inventory first. I can't get the inventory CmdLet to work. Is this correct:
Get-VBRTapeDrive|Start-VBRTapeInventory

That command seems to work fine after running an inventory from the GUI, IF there's a tape in it. But if it thinks the drive is empty, the command above crashes:
"Start-VBRTapeInventory : Cannot validate argument on parameter 'Medium'. The argument is null."

I tried this instead:
Get-VBRTapeLibrary|Start-VBRTapeInventory
But it doesn't do anything. It still thinks the drive is in the previous state (empty/loaded). What do I have to do to get it to do an inventory?

Also, when I read your response last night, there was a simpler command. Did you edit it?
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Re: Logging manual tape changes

Post by pshute »

pshute wrote:I tried this instead:
Get-VBRTapeLibrary|Start-VBRTapeInventory
But it doesn't do anything. It still thinks the drive is in the previous state (empty/loaded). What do I have to do to get it to do an inventory?
It seems that this command does work, but with a delay. It seems fairly quick when a tape has just been inserted, but takes over a minute when one has just been ejected (manually). (Timed at 95 seconds.)

How can the script tell when the inventory is finished?
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Logging manual tape changes

Post by veremin »

You can use -Wait switch, so that, script proceeds to the next line only when the previous command finishes:

Code: Select all

Start-VBRTapeInventory -Wait
Thanks.
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Re: Logging manual tape changes

Post by pshute »

Thanks, that does the job. Why does it take so long when the drive is empty?

And why does:
Get-VBRTapeDrive|Start-VBRTapeInventory
crash when the drive is empty?
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Re: Logging manual tape changes

Post by pshute »

And is there a way to get the results into the Veeam history? I can email them somewhere, but it would be nice to have a record that can be examined in Veeam itself.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Logging manual tape changes

Post by veremin »

crash when the drive is empty?
Can you initiate the same operation via GUI to limit the scope of potential suspects? With what particular error does it crash?
And is there a way to get the results into the Veeam history?
Could you elaborate on what results are meant here?

Thanks.
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Re: Logging manual tape changes

Post by pshute »

v.Eremin wrote: Can you initiate the same operation via GUI to limit the scope of potential suspects? With what particular error does it crash?
The command that crashes is:

Code: Select all

Get-VBRTapeDrive|Start-VBRTapeInventory
"Start-VBRTapeInventory : Cannot validate argument on parameter 'Medium'. The argument is null."
It will do that if it thinks the drive is empty.

I'm now using:

Code: Select all

Get-VBRTapeLibrary|Start-VBRTapeInventory
which works well. I'd like to know why the difference in behaviour.
Could you elaborate on what results are meant here?
The results I'm returning are the name of the tape in the drive, or "Drive empty". I would like to log that, somehow. The inventory command is automatically logged in the Veeam History, but not the name of the tape it found. I'd like to add that too, if possible.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Logging manual tape changes

Post by veremin »

I'd like to know why the difference in behaviour.
It must be related to the different objects that are returned by each cmdlet. Get-VBRDrive returns a drive object, while Get-VBRTapeLibrary a library one.

The Start-VBRTapeInvetory works either with library or with tape object. Thus, it fails when you pass a drive object to it through a pipeline.
The results I'm returning are the name of the tape in the drive, or "Drive empty". I would like to log that, somehow.
If I'm not mistaken, after inventory a tape stays in drive. So, once inventory is finished, you can query a drive and check what medium is present there. This should be your cassette that has been just inventoried.

Thanks.
pshute
Veteran
Posts: 254
Liked: 14 times
Joined: Nov 23, 2015 10:56 pm
Full Name: Peter Shute
Contact:

Re: Logging manual tape changes

Post by pshute »

In case anyone else is trying the same thing, I've noticed that Get-VBRTapeLibrary|Start-VBRTapeInventory -Wait fails after I've manually ejected and then inserted a brand new tape (i.e. unnamed). I'm now testing for inventory failure, and retrying if necessary:

Code: Select all

$i=Get-VBRTapeLibrary|Start-VBRTapeInventory -Wait
if ($i.Result -eq "Failed") {$i=Get-VBRTapeLibrary|Start-VBRTapeInventory -Wait}
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Logging manual tape changes

Post by veremin »

I'm wondering whether it crashes with the "Cannot validate argument" error which then goes away once the operation is retried. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests