Tuesday, March 27, 2012

DPM–How to force expire tape

 

Sometimes we hit in the situation that we’re FORCE to expire the oldest tape due to insufficient media for the backup.  This can’t be done from the DPM Console but with DPM Powershell Script.

Now copy the text that is the yellow wording below to a Text File.

----------------------------- Start of Script --------------------------------

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."
}
}
}

----------------------------- End of Script ---------------------------------

 

 

To Expire the tape

  • Rename the file save text file to force_expire.ps1
  • Put the file into your DPM bin directory.  In my case is D:\Program Files\Microsoft DPM\DPM\bin
  • Launch the DPM Management Shell

 

MYCBJ0751-SCR365

 

  • Type .\Force_Expire.ps1 and press enter in the DPM Management Shell then press enter.

 

MYCBJ0751-SCR366

  • Key in the DPM server name and press enter.

 

MYCBJ0751-SCR368

 

  • The Tape Library is display.  Copy and paste and press Enter.

 

MYCBJ0751-SCR373

  • Key in the slot of the tape that you wish to expire and press Enter.  The e.g. like Slot-<tape slot>.

image

  • Once it’s completed, go back to the DPM Console.

MYCBJ0751-SCR378

  • Now the tape is ready to be re-use.

 

Hope this helps you.

Thank you.

keynote : DPM 2010 expire tape, force expire tape, tapes to expire, expire force. tapes to expire in DPM 2010.

1 comment: