none
force mark tape as free doesn't work RRS feed

  • Question

  • 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 -Free

    After 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
    Wednesday, August 11, 2010 6:59 AM

Answers

All replies

  • 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.
    Thursday, August 12, 2010 9:22 PM
    Moderator
  • 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 $DPMLib

    PS 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:49

    p.s. Of course I also rebooted :)

    ciao. pf

    Tuesday, August 24, 2010 8:35 AM
  • 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.
    Tuesday, August 24, 2010 10:28 PM
    Moderator
  • 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é

    Thursday, August 26, 2010 10:16 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

     

    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

     


    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 6:32 AM
  • Before using the dpmtapeutil.exe to erase tapes, please implement this registry key. 

    Short Erase
    http://technet.microsoft.com/en-us/library/ff634195.aspx

    When 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:0x0

     

    Here 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:

        http://social.technet.microsoft.com/Forums/en-US/dpmtapebackuprecovery/thread/ab431377-665e-44e3-956d-e74a71000d77



    Regards, Mike J. [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, October 20, 2011 2:21 PM
    Moderator
  • 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 9:38 AM
  • 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-\\.\Tape2147483644


    Please 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.

    • Proposed as answer by ZeroCooL21 Sunday, December 22, 2013 12:22 PM
    Tuesday, September 18, 2012 5:07 PM
    Moderator
  • So, I was curious if you have come across an error with the script on single drive units running on Windows Server 2012 R2 with DPM?  I did the following:

    PS C:\Installs> ForceFree.ps1
    DPM server name: : dpm4
    Library name: : IBM ULTRIUM-HH4 SCSI Sequential Device
    Tape location: : drive-\\.\Tape2147483646

    and I get the following error:

    Set-Tape :  (ID: 24002)
    At C:\Installs\ForceFree.ps1:72 char:13
    +             Set-Tape -Tape $media -Free
    +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Set-DPMTape], MediaNotTrackableException
        + FullyQualifiedErrorId : MediaNotTrackable,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.MarkMedia

    The Error ID of 24002, on Microsoft's page, juist says MediaNotTrackable with no comments or guidance. I have come across a few different variations of the script that dont require me to specify drive-\\.\ but they all throw the exact same error.  Have any ideas?


    • Edited by LandJoh Friday, October 25, 2019 6:48 PM
    Friday, October 25, 2019 6:47 PM