problem automating the mounting of the tape library

The technical support forum for Firestreamer (the virtual tape library).
Locked
robp
Posts: 4
Joined: 15 Jun 2011, 19:36

Post by robp »

I am running DPM 2010 and using FireStreamer with great success. My only issue is, if I don't remember to manually unlock the tape door, mount the tape cartridge, and re-lock the tape door, I don't have a backup. Here's my attempt to automate the process - everything works but the actual FireStreamer tape mount - can anyone shed some light on this?

Remoting in and mounting the tapes on Saturday morning and dismounting them after the backup completes is getting to be a hassle - I've got to automate! (this is PowerShell)

Rob

PS C:\> # load firestreamer library
PS C:\> [System.Reflection.Assembly]::LoadFrom("c:\Program files\Cristalink\FsChanger\FirestreamerInterface.dll")

GAC Version Location
--- ------- --------
False v2.0.50727 c:\Program files\Cristalink\Fschanger\firestreamerInterface.dll

PS C:\> $FireTape = New-Object -TypeName Firestreamer.Driver.Controller
PS C:\> $FireTape.Connect
PS C:\> # find all DPM libraries
PS C:\> $AllLibraries = get-dpmlibrary -dpmservername candpm |where-object {$_.ProtectionGroups -ne ""}
PS C:\> # unlock DPM tape library door for all libraries
PS C:\> Unlock-DPMLibraryDoor -DPMLibrary $AllLibraries

Message
-------
Door has been unlocked for library Firestreamer Media Changer.

PS C:\> # load firestreamer tape library
PS C:\> $libraryNumber = 1
PS C:\> $mapfile = "F:\MediaMap.fsmap"
PS C:\> $FireTape.ChangerLoadMediaFromfile($libraryNumber,$mapfile)
The following exception occurred while retrieving member "ChangerLoadMediaFromfile": "Could not load file or assembly '
CristalinkNUtl' or one of its dependencies. An argument was out of its legal range. (Exception from HRESULT: 0x80131502)"
At line:1 char:35
+ $FireTape.ChangerLoadMediaFromfile <<<< ($libraryNumber,$mapfile)
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : CatchFromBaseGetMember

PS C:\> # lock library door
PS C:\> Lock-DPMLibraryDoor -DPMLibrary $AllLibraries

Message
-------
Door has been locked for library Firestreamer Media Changer.

PS C:\>
jsf
Cristalink Support
Posts: 300
Joined: 29 Aug 2010, 09:03

Post by jsf »

Can you post a copy of your script file? Thank you.
Best regards,
John Smith
Cristalink Support
robp
Posts: 4
Joined: 15 Jun 2011, 19:36

Post by robp »

Here's the script alone without comments or output:

[System.Reflection.Assembly]::LoadFrom("c:\Program files\Cristalink\FsChanger\FirestreamerInterface.dll")
$FireTape = New-Object -TypeName Firestreamer.Driver.Controller
$FireTape.Connect
$AllLibraries = get-dpmlibrary -dpmservername candpm |where-object {$_.ProtectionGroups -ne ""}
Unlock-DPMLibraryDoor -DPMLibrary $AllLibraries
$libraryNumber = 1
$mapfile = "F:\MediaMap.fsmap"
$FireTape.ChangerLoadMediaFromfile($libraryNumber,$mapfile)
Lock-DPMLibraryDoor -DPMLibrary $AllLibraries

To review, it all runs except the one line - loading the tapes from the media map file.

(I would rather find the library number (like $AllLibraries) rather than hard coding it into the script, and the same with the media map file but this was a quick attempt to get it going. I was thinking if it was a formatting issue, having the variable in the right format would fix it.)
jsf
Cristalink Support
Posts: 300
Joined: 29 Aug 2010, 09:03

Post by jsf »

I created c:\temp\script.ps1 with the following content:

Code: Select all

[System.Reflection.Assembly]::LoadFrom("c:\Program files\Cristalink\FsChanger\FirestreamerInterface.dll")
$FireTape = New-Object -TypeName Firestreamer.Driver.Controller
$FireTape.Connect()

$AllLibraries = get-dpmlibrary -dpmservername w2k8r2-dpm2010 |where-object {$_.ProtectionGroups -ne ""}
Unlock-DPMLibraryDoor -DPMLibrary $AllLibraries -Confirm:$false
$libraryNumber = 1
Write-Host "Library door unlocked"

$mapfile = "c:\temp\map.fsmap"
$FireTape.ChangerLoadMediaFromfile($libraryNumber,$mapfile)
Write-Host "Media map loaded"

Lock-DPMLibraryDoor -DPMLibrary $AllLibraries
Write-Host "Library door locked"
Then I opened "DPM Management Shell" (DPM 2010), typed c:\temp\script.ps1 and got the following output:
PS C:\Program Files\Microsoft DPM\DPM\bin> C:\temp\script.ps1

GAC Version Location
--- ------- --------
False v2.0.50727 c:\Program files\Cristalink\FsChanger\FirestreamerInte...

Success : True
Message : Door has been unlocked for library Firestreamer Media Changer.

Library door unlocked
Media map loaded

Success : True
Message : Door has been locked for library Firestreamer Media Changer.

Library door locked
Best regards,
John Smith
Cristalink Support
robp
Posts: 4
Joined: 15 Jun 2011, 19:36

Post by robp »

OK - I now have 2 scripts, dpm-load-tape.ps1 and dpm-unload-tape, and they are the same except in the unload version, I set $mapfile to "". Until I added the first line, it would run from the DPM console but wouldn't run from the powershell console. Now it does.

Add-PSSnapin -name Microsoft.DataProtectionManager.PowerShell -erroraction SilentlyContinue
[System.Reflection.Assembly]::LoadFrom("c:\Program files\Cristalink\FsChanger\FirestreamerInterface.dll")
$FireTape = New-Object -TypeName Firestreamer.Driver.Controller
$FireTape.Connect()
$AllLibraries = get-dpmlibrary -dpmservername candpm |where-object {$_.ProtectionGroups -ne ""}
Unlock-DPMLibraryDoor -DPMLibrary $AllLibraries -Confirm:$false
$libraryNumber = 1
$mapfile = "F:\MediaMap.fsmap"
$FireTape.ChangerLoadMediaFromfile($libraryNumber,$mapfile)
Lock-DPMLibraryDoor -DPMLibrary $AllLibraries

I can paste this into a powershell (or DPM) console, and it will run. I can also run the following from a command prompt:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "c:\scripts\dpm-unload-tape.ps1"

but if I build a scheduled task with exactly the same command it won't run. I looked this up, and found several suggestions, including running the 32-bit syswow64 version of powershell, and making an & 'argument' and that doesn't work. In fact, nothing runs. If I look into the history, it shows it ran with a tuypical run time of 1 second. The current run task setup is:

script: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
argument: & 'C:\scripts\dpm-load-tape.ps1'

I'm trying to automate the process, and so far, I've gone from manually unlocking the door/loading the library/locking the door, all from the GUI, to manually running a script from a comand prompt, which is a step backwards. I've made progress in that I have a powershell script that will duplicate from a command line what I do interactively in the GUI, but it needs to run automatically. I'm stumped - any help would be greatly appreciated.

Rob
jsf
Cristalink Support
Posts: 300
Joined: 29 Aug 2010, 09:03

Post by jsf »

As far as I understood, the problem is that when you "build a scheduled task with exactly the same command it won't run". You need to find out what fails, exactly. Redirect the output of the script to a file, and/or Insert into your script the commands that will dump debug info to a file (for example, "script started", "library unlocked" and so on). This way you can tell whether your script is executed at all, and if it is, which part of the script fails. I am sorry, but we cannot provide general support for PowerShell.

Note that the account the script is scheduled to run under does matter. It's very likely that F: is either invalid or points to a wrong drive when your script is executed non-interactively.
Best regards,
John Smith
Cristalink Support
Locked