Solved

DPM 2010 Script to run inventory, then mark tape as free

Posted on 2011-09-04
5
2,170 Views
Last Modified: 2012-05-12
HI There,

We recently have setup a DPM 2010 Server backing up our corporate network.
Our server has a stand alone LTO 5 tape drive.
Our tape calendar is a full backup following the days:
Monday,Tuesday, Wednesday, Thursday, Friday 1, Friday 2, Friday 3, Friday 4, Friday 5
Along with Month Ends and Week Ends.
Because we are not the most organised bunch, we would like whatever tape that gets put it to be written to so I have been using the script attached below.
The script works fine but requires the manual input of server name and tape drive name. It also fails if an inventory is not run prior to the script being ran.

So my question is:
Can someone show me how to automate the following and add an inventory to the start of the the script so I can run it as a scheduled task before each night's backup.
My server Name is: STL-DPM1
My Tape Drive Name is: Hewlett Packard LTO Ultrium-5 drive

Here is the current script:

 }
 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."
         }
   
 
}
0
Comment
Question by:St_Lukes
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:d3ath5tar
ID: 36481908
if the script is running directly on your dpm server;

$DPMServerName = $env:computername (if you are running this remotely then replace $env:computername with a string value.

then get your library details
$DPMLibrary = get-dpmlibrary -DPMServerName $DPMServerName

The library in your tape unit would normally be listed as the second entry, which is entry 1 as the devices start at 0.... but you could run the above once manually to be sure.... but when you know the next line would be..

Start-DPMLibraryInventory -DpmLibrary $DPMLibrary[1] (unless 1 -i,e, the second device, wasn't your library locatioN)

You could also a -DetailedInventory to the command if you want a thorough one...



 
0
 

Author Comment

by:St_Lukes
ID: 36481947
d3ath5tar:

Thanks for the info, unfortunately I have no idea about this scripting so I was looking for someone to put it together for me cheers. I will be running it locally also.
0
 
LVL 7

Expert Comment

by:d3ath5tar
ID: 36482049
OK....

Open a powershell window and run;
set-remoteexecutionpolicy remotesigned
Close powershell

Each line of script will do the trick if you run it on your local dpm server so open notepad and paste in;

$DPMServerName = $env:computername
$DPMLibrary = get-dpmlibrary -DPMServerName $DPMServerName
Start-DPMLibraryInventory -DpmLibrary $DPMLibrary[1]

Save all that in c:\support\DoInventory.ps1 and launch it from a scheduled task before your backup kicks off...

To schedule a powershell job as a task, open scheduled tasks and create your task as teh command;
powershell -command "& C:\support\DoInventory.ps1' "

As far as working out if the $DPMLibrary[1] is correct; open powershel and run the first two lines manually
Then typr $DPMLibrary on it own; it will list all your back up objects e.g.

Tape something or other
Library name something or other
maybe more devices

Eahc line is a line starting from 0, so look for the line with your library name in it... it should be then second line which is 1.

If it is not one, replace one with the correct array line number remembering to count lines starting from 0.

0
 
LVL 7

Accepted Solution

by:
d3ath5tar earned 500 total points
ID: 36482056
Ohhhhh I frogot a bit....

the first line of DoInventory.ps1 needs to be;
Add-PSSnapin -name Microsoft.DataProtectionManager.PowerShell

So the whole file is;
Add-PSSnapin -name Microsoft.DataProtectionManager.PowerShell
$DPMServerName = $env:computername
$DPMLibrary = get-dpmlibrary -DPMServerName $DPMServerName
Start-DPMLibraryInventory -DpmLibrary $DPMLibrary[1]

0
 

Author Closing Comment

by:St_Lukes
ID: 36563845
Was a bit staggered and hard to follow. Required further assistance.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We recently had an issue where out of nowhere, end users started indicating that their logins to our terminal server were just showing a "blank screen." After checking the usual suspects -- profiles, shell=explorer.exe in the registry, userinit.exe,…
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question