如何在 DPM 2012 中自动将磁带标记为可用?

如何在 DPM 2012 中自动将磁带标记为可用?

我有一台运行 System Center Data Protection Manager 2012 的备份服务器,连接到几个磁带驱动器(无磁带库)。当然,我也有一些磁带。磁带轮换是手动的。

这些磁带之前曾被 DPM 本身使用过(但服务器已完全重建)和其他备份软件使用过;它们不是空的。但它们不包含 DPM 知道和/或想要保留的数据,因此可以将它们标记为可用,而无需运行forcefreetape.ps1

当磁带放入驱动器时,需要执行清点,将其识别为导入的磁带,然后将其标记为可用;否则 DPM 将拒绝使用它。

我如何告诉 DPM 自动将这些导入的磁带视为免费磁带?当然,我会这样做不是如果真实的备份磁带恰好在到期日期之前被放入驱动器,则想要重复使用它们,因此解决方案应该将导入的磁带标记为免费,但不应该对真实的、未到期的磁带执行相同的操作。

答案1

与往常一样,需要一些脚本...

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
}

答案2

我遇到了完全相同的问题。问题是,上一个答案中的脚本没有考虑可能与 DPM 关联的所有设备。上述脚本的编写方式是,它采用设备 ID 为 [0] 的第一个设备。(通常分配给磁带驱动器而不是库)。因此,您必须在脚本中处理正确的设备。您可以发出 Get-DPMLibrary 命令来获取所有设备的列表。

获取 DPMLibrary -DPMServerName "你的服务器名称

这将按设备编号从低到高的顺序列出与 DPM 关联的所有设备。

该库通常会被列为第二个条目,即条目 1,因为设备从 0 开始....

(注意设备编号和 $DPMLibrary 变量添加的代码行 3)

我还删除了“Get-DPMTape $_ | Set-DPMTape -免费“它根本不起作用!我将其替换为:

$Tape = Get-Tape -DPMLibrary $DPMLibrary

套装-DPMTape-胶带$胶带-免费

注意:Set-DPMTape -Tape $Tape -Free 将产生错误。(不要惊慌)。这与已与保护组关联的磁带有关。无论如何,代码都会将所有磁带标记为可用。

(因此,只需复制下面的脚本替换您的设备 ID)....尽情享受吧:)

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]
}

答案3

以下脚本将搜索每个在线磁带库,然后将其中的每个过期磁带标记为可用。在您的 DPM 服务器上运行。

$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

相关内容