Tuesday, July 5, 2011

DPM–How to Erase the Tapes Manually before expire to be reuse.

I come across one of the many questions, someone asked me if they can erase the tapes manually before it’s expired.  They said they wanted to do some testing to backup to tapes but somehow they can’t be able to find the erasure in the GUI.

So I’m going to share how it is done using PowerShell.

 MY-HV-TES-003-180

Launch the DPM console.  Navigate to the ManagementLibraries .  Take note of it.  Slot 1 to Slot 9 .

Then now open a notepad.  Copy and paste the following (in yellow) to it :

param ([string] $DPMServerName, [string] $LibraryName, [string[]] $TapeLocationList)

if(("-?","-help") -contains $Args[0])
{
Write-Host "Usage: ForceFree-Tape.ps1 [[-DPMServerName] <Name of the DPM server>] [-LibraryName] <Name of the library> [-TapeLocationList] <Array of tape locations>"
Write-Host "Example: Force-FreeTape.ps1 -LibraryName "My library" -TapeLocationList Slot-1, Slot-7"
exit 0
}

if (!$DPMServerName)
{
$DPMServerName = Read-Host "DPM server name: "
if (!$DPMServerName)
{
Write-Error "Dpm server name not specified."
exit 1
}

}
if (!(Connect-DPMServer $DPMServerName))
{
Write-Error "Failed to connect To DPM server $DPMServerName"
exit 1
}

$library = @(Get-DPMLibrary $DPMServerName )
if ($library.count -eq 0)
{
Write-Error "Failed to find library with user friendly name $LibraryName"
exit 1
}

if (!$LibraryName)
{
$library | foreach {$_.userfriendlyname}
$LibraryName = Read-Host "Library name (cut & paste from above): "
if (!$LibraryName)
{

Write-Error "Library name not specified."
exit 1
}
}

if (!$TapeLocationList)
{
$tmp = Read-Host "Tape location: "
$TapeLocationList=$tmp.split(",")
write-host "Processing this slot list..."
$TapeLocationList
if (!$TapeLocationList)
{
Write-Error "Tape location not specified."
exit 1
}
}

foreach ($media in @(Get-Tape -DPMLibrary $library))
{
if ($TapeLocationList -contains $media.Location)
{
if ($media -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia])
{
foreach ($rp in @(Get-RecoveryPoint -Tape $media))
{
Get-RecoveryPoint -Datasource $rp.Datasource | Out-Null
Write-Verbose "Removing recovery point created at $($rp.RepresentedPointInTime) for tape in $($media.Location)."
Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false
}

Write-Verbose "Setting tape in $($media.Location) as free."
Set-Tape -Tape $media -Free
}
else
{
Write-Error "The tape in $($media.Location) is a cleaner tape."
}
}
}

 

Save the file and rename it with the extension .ps1

MY-HV-TES-003-181

In my example here, I have a file name as Tape_Erase.ps1 and stored in the D:\PowerShell Scripts directory.

MY-HV-TES-003-193

From the DPM console, I launch the DPM Management Shell (which is the PowerShell)

MY-HV-TES-003-194

Once launch you’ll be able to see the screen as above.

image

Then I change to the directory to where I save my PowerShell Script.  In my case I maneuvered to “D:\PowerShell Scripts”.

MY-HV-TES-003-204

To execute the PowerShell script I keyed in with a ./

In my example my file is name as tape_erase.ps1.  To execute the script I type as ./tape_erase.ps1 .

Then next I keyed in the DPM server name (that is with the tape library).  In my case is MY-VM-DPM-SEC01

Then I key in the tape slot that I want to erase the tape.

I keyed in as Slot-2

Note : the ones in pink are the ones that needs to be change accordingly to your naming of your PowerShell script and your DPM settings.

Then  you’ll be able to see the process followed.

MY-HV-TES-003-208

Another example as above, which I want to erase the tape in Slot-9.  e.g. In some cases the name of slot could be Slot-9 or Slot 9.  So it differs from one tape library to another.

Once it’s done, launch back the DPM Console.

MY-HV-TES-003-205

Click on the Management tab, then on the Libraries tab.

Select the tape that was erase earlier.  In my example is Slot 2<Right-click> on the tape and select Erase tape.

MY-HV-TES-003-206

Click Yes.

MY-HV-TES-003-207

Now the tape is erased and ready to be reuse.

Thank you and hope it helps you.  A special thanks also to Ruud Baars (of Microsoft) for sharing his scripting.

keywords : Data Protection Manager, erase tape before expire in DPM, how to erase tape manually in DPM, PowerShell script to erase tape manually in DPM.

3 comments:

  1. Very helpful post!

    you may want to add that if you want to run that on more than one slot at a time you can separate it with commas. Slot-1,Slot-2,Slot-3 otherwise you can sit in front of the console forever!

    Cheers,

    Gui

    ReplyDelete
  2. great post worked like a boss 100%

    ReplyDelete
  3. Systems Center - Virtualization: Dpm–How To Erase The Tapes Manually Before Expire To Be Reuse. >>>>> Download Now

    >>>>> Download Full

    Systems Center - Virtualization: Dpm–How To Erase The Tapes Manually Before Expire To Be Reuse. >>>>> Download LINK

    >>>>> Download Now

    Systems Center - Virtualization: Dpm–How To Erase The Tapes Manually Before Expire To Be Reuse. >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete