Backup Exec 2012 – Get-BEJobLog and Get-BEJobLogFiles


26.01.2013

I wanted to get names of bkf files (media) from Get-BEJobLog in Backup Exec 2012. Unfortunately Get-BEJobHistory | Get-BEJobLog outputs only log in string value. Due to this reason I created simple function for obtaining the names for particular media.

  • You cannot use the function for deduplication type of job because of image folder structure.
  • If you want to import  “Backup Exec Management Command Line Interface” into PowerShell session, you need to use  cmdlet Import-Module -Name BEMCLI.

Function Get-BEJobLogFiles

function Get-BEJobLogFiles{
 param ( 
 [Parameter(Mandatory=$True,ValueFromPipeline=$true)]
 [String]$BEJobLog
 )
 $Files = @()
 foreach($Str in $BEJobLog){
 $SplitString = ""
 $SplitString = $Str.Split("`n") | Select-String -Pattern "B2D" -SimpleMatch |sort -Unique
 foreach($Line in $SplitString){
 $StrFile = ""
 $StrFile = $Line.toString()
 $StrFile = $StrFile.Substring($StrFile.indexof(":")+2)
 if($StrFile -ne $null){
 $Files += $StrFile
 }
 } 
 }
 return $Files
}

Download: Get-BEJobLogFiles

If you expect more that one logs (i.e. caused by more Get-BEJobHistory)  you will need to use:

Get-BEJobHistory | Get-BEJobLog | %{ $_ | Get-BEJobLogFiles }

Example:

PS C:\> Get-BEJobHistory | Where-Object {(($_.name -like "*Monthly Full*") -and ($_.JobStatus -like "Succeeded") -and ($
_.StartTime -gt (get-date).adddays(-2)))} | Get-BEJobLog | %{ $_ | Get-BEJobLogFiles }
B2D002673
B2D002675
B2D002677
B2D002679
B2D002683
B2D002684
B2D002685
B2D002686
B2D002688
B2D002690
B2D002692
B2D002694
B2D002695
B2D002696
B2D002697
B2D002708
B2D002709
B2D002710
B2D002713
B2D002711
B2D002715
B2D002717
B2D002719
B2D002712
B2D002714
B2D002716
B2D002718

How to find related media on disk? Example below could help you. Please ignore related names for variables because it is used from different script:

# Retention period 
$Retention = -8

# Backup Exec Storages
$DiskE = "E:\BEData"
$DiskG = "G:\BEData"
$DiskH = "H:\BEData"

# Backup Selection (Error Job)
$ErrorJobsMedia = Get-BEJobHistory | Where-Object {(($_.name -like "*Monthly Full*") -and ($_.JobStatus -like "Succeeded") -and ($_.StartTime -gt (get-date).adddays(-2)))} | Get-BEJobLog | %{ $_ | Get-BEJobLogFiles }

# File Selection
$BackupStorages = @()
$BackupStorages += Get-ChildItem -path $DiskE | where-object {$_.Name -like "*.bkf"}
$BackupStorages += Get-ChildItem -path $DiskG | where-object {$_.Name -like "*.bkf"}
$BackupStorages += Get-ChildItem -path $DiskH | where-object {$_.Name -like "*.bkf"}

# Backup files determination
$BackupFiles = @()
foreach ($ErrorJobsMed in $ErrorJobsMedia){
 foreach ($BckFile in $BackupStorages){
 $BckFileTemp = ($BckFile.name).toString()
 $BckFileTemp = $BckFileTemp.substring(0,$BckFileTemp.indexof("."))
 if($ErrorJobsMed -match $BckFileTemp){
 $BackupFiles += $BckFile
 } 
 }
}
PS C:\> $BackupFiles | select fullname

FullName
--------
H:\BEData\B2D002673.bkf
H:\BEData\B2D002675.bkf
H:\BEData\B2D002677.bkf
H:\BEData\B2D002679.bkf
H:\BEData\B2D002683.bkf
H:\BEData\B2D002684.bkf
G:\BEData\B2D002685.bkf
G:\BEData\B2D002686.bkf
G:\BEData\B2D002688.bkf
G:\BEData\B2D002690.bkf
G:\BEData\B2D002692.bkf
G:\BEData\B2D002694.bkf
G:\BEData\B2D002695.bkf
G:\BEData\B2D002696.bkf
G:\BEData\B2D002697.bkf
E:\BEData\B2D002708.bkf
E:\BEData\B2D002709.bkf
E:\BEData\B2D002710.bkf
E:\BEData\B2D002713.bkf
H:\BEData\B2D002711.bkf
H:\BEData\B2D002715.bkf
H:\BEData\B2D002717.bkf
H:\BEData\B2D002719.bkf
G:\BEData\B2D002712.bkf
G:\BEData\B2D002714.bkf
G:\BEData\B2D002716.bkf
G:\BEData\B2D002718.bkf
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s