Tuesday, September 1, 2009

Script to resolve: Free tape threshold reached

When you have a tape library for which you change the tapes on a daily or weekly basis you properly run in to the following warning: Free tape threshold reached.

The number of free tapes in the Tape Library ,name> is less than or equals the threshold value of #. You must add tape to the library and it as free in order to prevent future backups from failing (ID 3305)

You receive this warning even when there are enough expired tapes available in the tape library. You get this warning because DPM checks the number of free tapes, in spite of the fact that DPM can write to expired tapes as well.
image

The advised resolution in DPM is manually mark all expired tapes as free. However a real IT-admin does not like manual labor. Therefore we created a PowerShell script that checks for expired tapes and marks them free.
If you run the script manually it looks like this:
image

Powershell script:

param ([string] $DPMServerName)
add-PSSnapin Microsoft.DataProtectionManager.PowerShell
if(("-?","-help") -contains $args[0])
{
    Write-Host "Description: This script marks all expired tapes as free"
    Write-Host "Usage: MarkExpiredTapesAsFree.ps1 [-DPMServerName] <Name of the DPM server>"
    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
}
$libraryList = Get-DPMLibrary -DPMServerName $DPMServerName
foreach ($library in $libraryList)
{
    $expiredTapeList = @(Get-Tape -DPMLibrary $library |
    ? {$_ -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia] -and

$_.DatasetState -eq "Recyclable"})
    if ($expiredTapeList.Length -gt 0)
    {
        Write-Host "Marking $($expiredTapeList.Length) tape(s) as free in $($library.UserFriendlyName)."
        Set-Tape -Tape $expiredTapeList -Free
        $expiredTapeList | select Location
    }

}

We have scheduled this script to run daily using the Windows task scheduler. Expired tapes are now mark as free on a daily basis

In order to schedule a Powershell command you need to create a cmd that calls the Powershell script. The command file is listed below

command file:

powershell -command "& 'd:\ps_scripts\MarkExpiredTapesAsFree.ps1' <servername>"

Thanks to Mischa for his help with the script.

3 comments:

  1. It would be good to document the fact that you can adjust the free tape threshold by changing MinFreeTapeThreshold in the tbl_MM_MediaPool table.

    ReplyDelete
  2. I only see MinThresholdForFreePool in tbl_MM_MediaPool table. Is it the same value?

    ReplyDelete
  3. Good one ; well explained in following blog ..might be helpful for those who using dpm for first time

    http://cshakkeer.blogspot.com/2012/07/dpm-2010-how-to-free-tapes-manually.html

    ReplyDelete