2

I have a backup server running System Center Data Protection Manager 2012, connected to a couple of tape drives (no library). I also have, of course, some tapes. Tape rotation is manual.

The tape have been used before, by DPM itself (but the server has been completely rebuilt) and by other backup softwares; they are not emtpy. But they contain no data that DPM knows and/or wants to preserve, so they can be marked as free without having to run forcefreetape.ps1.

When a tape is placed into the drive, it is required to perform an inventory, have it recognized as an imported tape and then mark it as free; otherwise DPM will simply refuse to use it.

How can I tell DPM to automatically treat those imported tapes as free? And, of course, I do not want to reuse real backup tapes if by chance they get put into the drives before their expiration date, so the solution should mark imported tapes as free, but should not do the same with real, non-expired tapes.

1
  • Is this working? I got error: Start-DPMLibraryInventory : Operation failed because Stand Alone Drive Tape Library IBM ULTRIUM 5 HH 3580 TAPE DRIVE is offline. (ID: 31137) At C:\Program Files\Microsoft System Center 2012\DPM\DPM\bin\AutoMarkExpiredTapesAsFreeAfterDetailInventory.ps1:9 char:40 + $result = Start-DPMLibraryInventory <<<< -DPMLibrary $_ -DetailedInventory + CategoryInfo : NotSpecified: (:) [Start-DPMLibraryInventory], LibraryOfflineException + FullyQualifiedErrorId : LibraryOffline,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.StartInventory
    – user237757
    Aug 15, 2014 at 2:52

3 Answers 3

2

As usual, a bit of scripting is needed...

Import-Module DataProtectionManager

$Server = Get-Content env:computername

Get-DPMLibrary $Server | foreach {
    write-host
    write-host Starting inventory for library $_.UserFriendlyName

    $result = Start-DPMLibraryInventory -DPMLibrary $_ -DetailedInventory

    while (!$result.HasCompleted)
    {
        write-host -NoNewline "."
        sleep 1
    }

    write-host
    write-host Inventory complete for library $_.UserFriendlyName

    write-host Setting tape in library $_.UserFriendlyName as free

    Get-DPMTape $_ | Set-DPMTape -Free

    write-host Operation completed for library $_.UserFriendlyName
}
0

I was having the the EXACT SAME issue. The problem is that the script above in the previous answer, doesn't account for all the devices that may be associated with DPM. The way the above script is written, it takes the very first device with a device ID of [0]. (Which is usually assigned to the Tape Drive & not the Library). So you must address the proper device in the script. You can issue a Get-DPMLibrary command to get a listing of all your devices.

Get-DPMLibrary -DPMServerName "yourservername"

This will list all devices associated with DPM in the order of lowest device number [0] to highest.

The library would normally be listed as the second entry, which is entry 1 as the devices start at 0....

(Notice the device number & the added code line 3 for the $DPMLibrary variable)

I also removed "Get-DPMTape $_ | Set-DPMTape -Free" It simply didn't work ! I replaced it with:

$Tape = Get-Tape -DPMLibrary $DPMLibrary

Set-DPMTape -Tape $Tape -Free

Note: The Set-DPMTape -Tape $Tape -Free Will produce errors. (don't be alarmed). It has to do with tapes already being associated with protection groups. The code WILL mark all the tapes as free none-the-less.

(So just copy the script below replacing your device ID).... enjoy :)

Import-Module DataProtectionManager

$Server = Get-Content env:computername

$DPMLibrary = get-dpmlibrary -DPMServerName $Server

Get-DPMLibrary $Server | foreach {
    write-host
    write-host Starting inventory for library $DPMLibrary[2]

    $result = Start-DPMLibraryInventory -DPMLibrary $DPMLibrary[2] -DetailedInventory

    while (!$result.HasCompleted)
    {
        write-host -NoNewline "."
        sleep 1
    }

    write-host
    write-host Inventory complete for library $DPMLibrary[2]

    write-host Setting tape in library $DPMLibrary[2] as free

    $Tape = Get-Tape -DPMLibrary $DPMLibrary
    Set-DPMTape -Tape $Tape -Free

    write-host Operation completed for library $DPMLibrary[2]
}
0

The following script will search for every online tape library then mark every expired tape in it as free. Run on your DPM server.

$sw = [Diagnostics.Stopwatch]::StartNew()
Import-Module DataProtectionManager

$DPMServerName = Get-Content env:computername

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

$libraryList = @()
$libraryList = Get-DPMLibrary -DPMServerName $DPMServerName | where {$_.Status -eq 'Enabled'}
foreach ($library in $libraryList) 
{ 
    write-host
    write-host Starting inventory for library $library.UserFriendlyName
    write-host "This operation can take a long time, please be patient..."
    $result = Start-DPMLibraryInventory -DPMLibrary $library -DetailedInventory
    write-host
    write-host Inventory complete for library $library.UserFriendlyName
    write-host
    $expiredTapeList = @(Get-Tape -DPMLibrary $library | ? {$_ -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia] -and $_.DatasetState -eq "Recyclable"}) 
    if ($expiredTapeList.Length -gt 0) 
    { 
        $expiredTapeList #| Export-Csv -NoTypeInformation -Encoding UTF8 -Path $Exported_csv_path -Force
        Write-Host "Marking $($expiredTapeList.Length) tape(s) as free in $($library.UserFriendlyName)." 
        foreach ($expiredTape_ in $expiredTapeList)
        {
            Write-host "Setting tape Barcode $($expiredTape_.Barcode) in $($expiredTape_.Location) as free."
            Set-Tape -Tape $expiredTape_ -Free
        }
    } else {Write-Host "No Expired Tapes were Found in $($library.UserFriendlyName)" -ForegroundColor Red}

}
$sw.Stop()
Write-Host "`n Total job running time ...." $sw.Elapsed
2
  • Why add another answer with the exact same content as the existing ones?
    – Massimo
    Nov 19, 2017 at 15:52
  • This one looks for online tape libraries only , in case there were other tape libraries that are no longer available DPM still lists them when Get-DPMLibrary unless you filter the results.
    – Alon Or
    Nov 23, 2017 at 7:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .