force mark tape as free doesn't work
-
Wednesday, August 11, 2010 6:59 AM
Hi @ all,
I am using powershell for forcing tapes as free which are belonging to a single tape drive.
Here is the script:
$LIB = Get-DPMLibrary -DPMServerName server
$TP1 = Get-Tape -DPMLibrary $LIB foreach ($rp in @(Get-RecoveryPoint -Tape $TP1)) { Get-RecoveryPoint -Datasource $rp.Datasource | Out-Null Write-Verbose "Removing recovery point created at $($rp.RepresentedPointInTime) for tape." Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false } Write-Verbose "Setting tape as free." Set-Tape -Tape $TP1 -FreeAfter running the script it throws an error which indicates, that recoverypoints can't be removed because they still belong to a protection group. Error ID: 31116
Any hints?
Cheers,
André
- Changed Type André Loske Thursday, August 26, 2010 10:17 AM not solved
All Replies
-
Thursday, August 12, 2010 9:22 PMModerator
Please try this script.
param ([string] $DPMServerName, [string] $LibraryName)
if(("-?","-help") -contains $args[0])
{
Write-Host "Usage: ForceFree-Tape.ps1 [[-DPMServerName] <Name of the DPM server>] [-LibraryName] <Name of the library>
Write-Host "Example: Force-FreeTape.ps1 -Dpmservername SDPM01 -LibraryName My library
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 (!(Connect-DPMServer $DPMServerName))
{
Write-Error "Failed to connect To DPM server $DPMServerName"
exit 1
}
$library = Get-DPMLibrary $DPMServerName | where {$_.UserFriendlyName -eq $LibraryName}
write-host "Getting library..."
if (!$library)
{
Write-Error "Failed to find library with user friendly name $LibraryName"
exit 1
}
foreach ($media in @(Get-Tape -DPMLibrary $library))
{
write-host "Getting media..."if ($media -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia])
{
foreach ($rp in @(Get-RecoveryPoint -Tape $media))
{
write-host "Getting recovery point..."
Get-RecoveryPoint -Datasource $rp.Datasource | Out-Null
Write-Verbose "Removing recovery point created at $($rp.RepresentedPointInTime) for tape in $($media.Location)."
write-host "Force removing recovery point..."
Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false
}
Write-Verbose "Setting tape in $($media.Location) as free."
write-host "Setting tape as free..."
Set-Tape -Tape $media -Free
}
else
{
Write-Error "The tape in $($media.Location) is a cleaner tape."
}
}
Regards, Mike J [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.- Proposed As Answer by Mike JacquetMicrosoft Employee, Moderator Thursday, August 12, 2010 9:22 PM
- Marked As Answer by Parag Agrawal [MSFT]Moderator Tuesday, August 17, 2010 8:23 AM
-
Tuesday, August 24, 2010 8:35 AM
Mike, sorry your script is more "detailed", but it uses Set-Tape as the André one.
I'm verifying the same issue; I stop protection, the UI does not show anything in the Management/Libraries/Protection Group, but the DPM2010 always fires 31116! Set-Tape brings to the same result.
$DPMLib = Get-DPMLibrary -DPMServerName "SRV-BACKUP"
$Tape = Get-Tape -DPMLibrary $DPMLibPS C:\Users\Administrator.DOMAIN> write-host $Tape[1]
Id = 86a1fcfb-a039-4f15-9f2c-d97cc2f23ead
LibraryId = c07a0c13-9fff-406f-b272-e367e99ce38e
IsOffline = False
Location = Slot-40
Label = HYPERV Full-LT-1Weeks-Copy0-00000004
Type = TapeArchiveMedia
StateInDrive = None
BarcodeState = NotExisting
BarcodeValue =
MediaPoolId = 6e0056c1-fa61-4b6c-97a4-3de18084240a
MediaPoolType = Admin
OmidState = Recognized
IsOmidChangeNeeded = False
IsSuspect = False
IsOffsiteReady = NotComputed
DatasetState = Valid
CreationDate = 21/08/2010 23:21:22
ModifiedDate = 22/08/2010 00:04:49p.s. Of course I also rebooted :)
ciao. pf
-
Tuesday, August 24, 2010 10:28 PMModerator
I think you should try to run through the commands manually and see if this command is failing for any of the recovery points on that tape.
Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false
Once all the recovery points are succesfully deleted, then the tape should be able to be marked free.
Regards, Mike J [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights. -
Thursday, August 26, 2010 10:16 AM
Hi Mike,
thanks for the script. I tried to run it against a tape which has one recoverypoint on it but it didn't work. I get the same error like above.
cheers,
André
-
Monday, September 20, 2010 5:28 PM
I've just recently used this script utility to mark a tape as free in dpm2010. Just beware of the typo in v3.4 of the script as noted in the blog's comments:
http://blogs.technet.com/b/dpm/archive/2010/07/09/the-search-for-dpm-tape-utilities-stops-here.aspx
- Proposed As Answer by Mike JacquetMicrosoft Employee, Moderator Monday, September 20, 2010 11:56 PM
- Marked As Answer by Mike JacquetMicrosoft Employee, Moderator Monday, September 27, 2010 2:07 PM
-
Thursday, October 20, 2011 6:32 AM
I've just recently used this script utility to mark a tape as free in dpm2010. Just beware of the typo in v3.4 of the script as noted in the blog's comments:
http://blogs.technet.com/b/dpm/archive/2010/07/09/the-search-for-dpm-tape-utilities-stops-here.aspx
Thanks mate but when i look at this page it looks like it haves a user interface (seems not after downloading).When i run the script with powershell then it created a log i don't get it wat i need to do to get the tape marked a free!,
I tried to read the guide but stil...
Maybe it's because i lagg of experience with powershell but please help me..
-
Thursday, October 20, 2011 2:21 PMModerator
Before using the dpmtapeutil.exe to erase tapes, please implement this registry key.
Short Erase
http://technet.microsoft.com/en-us/library/ff634195.aspxWhen a user erases a tape, by default, DPM will do a long erase on that tape. DPM 2010 has introduced the ability to do a short erase now. Simply navigate to the following registry location and add the DWORD key with the default vale:
HKLM\Software\Microsoft\Microsoft Data Protection Manager\Agent
REG_DWORD:UseShortErase:0x0Here are some examples of the dpmtapeutil.exe commands for erasing tapes.
NOTE: -batch does not prompt to confirm, so use with care.
Example-1 eject offsite ready tapes
.\dpmtapeutil.ps1 -batch -inventory -search "state=offsiteready" -eject
Example-2 Schedule forcefree tape for expired tapes every monday at 10:00am
.\dpmtapeutil.ps1 -search "state=recyclable" -forcefree –schedule “Enable|Weekly|Mon|10:00”
Example-3 Schedule tapeerase tape for expired tapes every 1 day at 10:00am
.\dpmtapeutil.ps1 -search "state=recyclable" -tapeerase –schedule “Enable|daily|1|10:00”
Example-4 tape erase for tapes that are free but contain data
.\dpmtapeutil.ps1 -batch -search "state=freedata" -tapeerase -override
Example-5 tape erase for ALL tapes in the library at noon everyday M-F (-override will force expiration of rp's before erasing).\dpmtapeutil.ps1 -batch -tapeerase -override –schedule “Enable|weekly|Mon, Tue, Wed, Thu, Fri|12:00”
example-6 tape erase all tapes that are in an unknown (raw tape) state.
.\dpmtapeutil.ps1 -batch -search “state=unknown” -tapeerase -override
If you don't need to schedule the erase and just need to free a tape manually, then use one fo these solutions.
You can use the following power shell script to expire all RP on a given tape, then mark it free.
http://blogs.technet.com/dpm/archive/2007/09/04/cli-script-force-mark-tape-as-free.aspx
If you have a standalone tape drive - get the script from this post:
Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights. -
Tuesday, September 18, 2012 9:38 AM
Please try this script.
param ([string] $DPMServerName, [string] $LibraryName)
if(("-?","-help") -contains $args[0])
{
Write-Host "Usage: ForceFree-Tape.ps1 [[-DPMServerName] <Name of the DPM server>] [-LibraryName] <Name of the library>
Write-Host "Example: Force-FreeTape.ps1 -Dpmservername SDPM01 -LibraryName My library
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 (!(Connect-DPMServer $DPMServerName))
{
Write-Error "Failed to connect To DPM server $DPMServerName"
exit 1
}
$library = Get-DPMLibrary $DPMServerName | where {$_.UserFriendlyName -eq $LibraryName}
write-host "Getting library..."
if (!$library)
{
Write-Error "Failed to find library with user friendly name $LibraryName"
exit 1
}
foreach ($media in @(Get-Tape -DPMLibrary $library))
{
write-host "Getting media..."if ($media -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia])
{
foreach ($rp in @(Get-RecoveryPoint -Tape $media))
{
write-host "Getting recovery point..."
Get-RecoveryPoint -Datasource $rp.Datasource | Out-Null
Write-Verbose "Removing recovery point created at $($rp.RepresentedPointInTime) for tape in $($media.Location)."
write-host "Force removing recovery point..."
Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false
}
Write-Verbose "Setting tape in $($media.Location) as free."
write-host "Setting tape as free..."
Set-Tape -Tape $media -Free
}
else
{
Write-Error "The tape in $($media.Location) is a cleaner tape."
}
}
Regards, Mike J [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.Hi Mike, first of all thanks voor the script.
when i enter backup server name as first question the it goed to library name.. anyone know where to find it?
I tried Quantum LTO 4 drive but that didnt work.. the cmd window just dissapearess..
Thanks in advance!
-
Tuesday, September 18, 2012 5:07 PMModerator
Hello Rolando88,
You can copy-paste the library friendly name from the output of get-dpmlibrary command before you run the force-freetape.ps1.
If you are using the script on a standalone tape device (versus a library with multiple slots), you have to fill in the following for tape location:
Drive-\\.\Tape0 where \\.\Tape0 is the windows symbolic name of the device when you highlight your tape drive in the DPM Console.
Example:
PS C:\Program Files\Microsoft DPM\DPM\bin> force-freetape.ps1
DPM server name: : dpm1
Library name: : Quantum LTO 4 drive
Tape location: : drive-\\.\Tape2147483644Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.

