Problem: I wanted to use a DAT 72 tape that previously had data written to it. When trying to free the tape I received the following error:
The selected tapes cannot be erased because they belong to protection groupsSolution: The tape cannot be released via DPM 2010 GUI. I found the following PowerShell script that allowed me to use the tape:
----------------------------- Start of Script --------------------------------
param ([string] $DPMServerName, [string] $LibraryName, [string[]] $TapeLocationList)
if(("-?","-help") -contains $Args[0])
{Write-Host "Usage: ForceFree-Tape.ps1 [[-DPMServerName]] [-LibraryName] [-TapeLocationList] " Write-Host "Example: Force-FreeTape.ps1 -LibraryName "My library" -TapeLocationList Slot-1, Slot-7"exit 0
}
{Write-Host "Usage: ForceFree-Tape.ps1 [[-DPMServerName]
}
if (!$DPMServerName)
{$DPMServerName = Read-Host "DPM server name: "if (!$DPMServerName)
{Write-Error "Dpm server name not specified."exit 1
}
{$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
}
{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
}
{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)
{
{$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..."$TapeLocationListif (!$TapeLocationList)
{Write-Error "Tape location not specified."exit 1
}
}
{$tmp = Read-Host "Tape location: "$TapeLocationList=$tmp.split(",")write-host "Processing this slot list..."$TapeLocationListif (!$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-NullWrite-Verbose "Removing recovery point created at $($rp.RepresentedPointInTime) for tape in $($media.Location)."Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false}
{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-NullWrite-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 ---------------------------------
No comments:
Post a Comment