Microsoft Enterprise Platforms Support: Windows Server Core Team
When running System Center Data Protection Manager 2007 and utilizing the DPM tape libraries capability for protection, it may be necessary to expire tape recovery points prior to “Expires On” date. Tapes which have unexpired data cannot be marked as free from the UI in the DPM Administrators console but sometimes (esp. while testing) users need to override this behavior. The script below allows a user to mark any tape as free so that it’s available for protection by DPM. This same script can be utilized for tape libraries or stand alone tape devices.
To view the expiry date for a tape you can open the DPM Administrator console, click on Management and select the Libraries tab. Identify the tape of interest, right click and select “View tape contents”. This will display a list of recovery points on the tape and the “Expires on” date.
Running the script below will delete ALL the recovery points on the tape and mark it as “Free (contains data)”. This script cannot be used to selectively choose particular recovery points to delete.
CLI Script: Force mark tape as free is also documented at http://blogs.technet.com/dpm/archive/2007/09/04/cli-script-force-mark-tape-as-free.aspx
RESOLUTION:
Copy the script below to Notepad and save it to C:\Program Files\Microsoft DPM\DPM\bin folder using a descriptive file name. This is the default installation locate for DPM 2007 but the path may vary if DPM 2007 is installed to an alternate location. Be sure to change the file extension to .ps1 then open the DPM Management Shell. The usage and examples of scripts can be found by calling them with ‘-?’ or ‘-help’ from inside DPM Management Shell.
When you run this it will show confirmation that it is removing recovery points and marking tape as free. If this returns immediately and does not give any output, the parameters you put in were probably wrong. SEE EXPECTED OUTPUT BELOW.
COPY AND PASTE FROM HERE>>>
#REM: http://blogs.technet.com/dpm/archive/2007/09/04/cli-script-force-mark-tape-as-free.aspx
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 (!$LibraryName) { $LibraryName = Read-Host "Library name: "
if (!$LibraryName) { Write-Error "Library name not specified." exit 1 } }
if (!$TapeLocationList) { $TapeLocationList = Read-Host "Tape location: "
if (!$TapeLocationList) { Write-Error "Tape location not specified." exit 1 } }
if (!(Connect-DPMServer $DPMServerName)) { Write-Error "Failed to connect To DPM server $DPMServerName" exit 1 }
$library = Get-DPMLibrary $DPMServerName | where {$_.UserFriendlyName -eq $LibraryName}
if (!$library) { Write-Error "Failed to find library with user friendly name $LibraryName" 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." } } }
Tape Library Devices:
NOTE: In the example below the script was named Force-FreeTape.ps1.
PS C:\Program Files\Microsoft DPM\DPM\bin> Force-FreeTape.ps1 DPM server name: : Pss-DPM2007 Library name: : Sony LIB-162 Medium Changer Tape location: : Slot-5 The operation will remove the following recovery point(s) because they have dependencies on each other:
Wednesday, October 29, 2008 7:00:09 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Friday, October 31, 2008 7:00:09 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Thursday, October 30, 2008 7:00:11 AM The operation will remove the following recovery point(s) because they have dependencies on each other: Wednesday, October 29, 2008 7:00:09 AM The operation will remove the following recovery point(s) because they have dependencies on each other: Thursday, October 30, 2008 7:00:09 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Friday, October 31, 2008 7:00:09 AM
PS C:\Program Files\Microsoft DPM\DPM\bin>
StandAlone Tape Devices:
NOTE: You can use the same script on a standalone tape device, you have to fill in the following for tape location:
Drive-\\.\Tape0
where \\.\Tape0 is the “Windows name of the drive” that is located in the Details pane when selecting the tape. (\\.\Tape# Where # is serial number in most cases)
PS C:\Program Files\Microsoft DPM\DPM\bin> Force-FreeTape.ps1 DPM server name: : sdpm02 Library name: : firestreamer tape drive Tape location: : drive-\\.\Tape2147483644 The operation will remove the following recovery point(s) because they have dependencies on each other:
Tuesday, November 04, 2008 12:10:19 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Monday, November 03, 2008 9:03:11 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Monday, November 03, 2008 9:02:29 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Sunday, November 02, 2008 12:10:09 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Thursday, October 30, 2008 9:02:35 PM The operation will remove the following recovery point(s) because they have dependencies on each other: Thursday, October 23, 2008 9:02:34 PM
Author: Thomas O'Malley Senior Support Escalation Engineer Microsoft Corporation
PingBack from http://diggffxi.info/tags/101/?p=2374
Hi,
m< question is:
What must be changed in the posted script so that it is possible to run it without user input?
My problem is, that often my Tape-Backups fail with the "no free tape" error, even though I use 5 tapes for long-term-protection with a 1 day backup cycle.
So from monday-friday, each day is a new tape, saturday-sunday, its the friday tape and these two jobs fail but that is ok and to be expected. But sometimes the jobs during the week fail with the same error as those on the weekend..
And to do something about it, I thought I could use the above sript as a scheduled task, but for that I would have to "hard-code" my server-name and such.
And I don't really know how and where to replace them in the script above. Can somebody please point out the necessary steps?
@Me_vs_PM this reply is a year late but might help someone... I simply changed the line of code that says, in laymans terms "if the user sets the name of $DPMServerName to nothing (that is, just presses enter and skips entering the DPMServerName altogether) write to the screen: 'DPMServerName not specified.'"
I changed that line to say, again in laymans terms: "if the user sets the name of $DPMServerName to nothing, set $DPMServerName to DPMBACKUP." In my case, my DPM server is called DPMBACKUP.
Making this change, and a similar one for the tape library, meant I just had to hit enter twice and it would automatically fill in the names of my DPMServerName and LibraryName. The lines of code I've changed is below. Simply replace this text with the same text from the example above, and replace the words "DPMBACKUP" with your dpm server name, and the words "Hewlett Packard MSL G3 Series library (x64 based)" with your library name.
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 -DPMServerName "DPMBACKUP" -LibraryName "Hewlett Packard MSL G3 Series library (x64 based)" -TapeLocationList Slot-1, Slot-2"
exit 0
}
if (!$DPMServerName)
$DPMServerName = Read-Host "DPM server name: "
$DPMServerName = "DPMBACKUP"
Write-Host "DPMServerName set to $DPMServerName"
if (!$LibraryName)
$LibraryName = Read-Host "Library name: "
$LibraryName = "Hewlett Packard MSL G3 Series library (x64 based)"
Write-Host "Library name set to $LibraryName"
To make it easier to cut and paste, here is the full .ps1 code with the changes I've made. Replace the words "DPMBACKUP" with the name of your dpm server, and the words "Hewlett Packard MSL G3 Series library (x64 based)" with the name of your library name.
if (!$TapeLocationList)
$TapeLocationList = Read-Host "Tape location: "
Write-Error "Tape location not specified."
exit 1
if (!(Connect-DPMServer $DPMServerName))
Write-Error "Failed to connect To DPM server $DPMServerName"
if (!$library)
Write-Error "Failed to find library with user friendly name $LibraryName"
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."
doesn't work. i go through the process, get no errors, but nothing changes.