PowerShell script exchange
Post Reply
nunciate
Veteran
Posts: 257
Liked: 40 times
Joined: May 21, 2013 9:08 pm
Full Name: Alan Wells
Contact:

Full Backup Schedule Report

Post by nunciate »

I have been trying to figure out how to create a report of all my tape jobs that shows what day they are scheduled for a full backup to tape.
I can edit each tape job, choose the Media Pool Tab, Choose the Schedule button and see the day selected for the full backup.
I have a lot of jobs and want to export all of them to a .csv file with a PowerShell command that gives me what that day is set to.

Does anyone have a script for that?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Full Backup Schedule Report

Post by oleg.feoktistov »

Hi Alan,

If the idea is to grab only the days full backup is scheduled on regardless of the schedule and tape job type, you might need something like this:

Code: Select all

$tapeJobs = Get-VBRTapeJob 
foreach ($tapeJob in $tapeJobs) {
  if ($tapeJob.FullBackupPolicy.Type -eq 'Monthly') {
    $days = $tapeJob.FullBackupPolicy.MonthlyOptions.DayOfWeek
  }
  elseif ($tapeJob.FullBackupPolicy.Type -eq 'WeeklyOnDays') {
    $days = $tapeJob.FullBackupPolicy.WeeklyOnDays
  }
  elseif ($tapeJob.FullBackupPolicy.Type -eq 'Daily') {
    $days = $tapeJob.FullBackupPolicy.DailyOptions.DayOfWeek
  }
  else {
    $days = 'Unknown'
  }
  $tapeJob | select Name, FullBackupMediaPool, @{n='FullBackupPolicyType';e={$_.FullBackupPolicy.Type}}, `
  @{n='FullScheduleDays';e={$days}} 
}
Otherwise, the script and validation complexity would depend on what exactly you need to gather and reflect. Another example with properties filtering based on schedule and tape job types:

Code: Select all

$tapeJobs = Get-VBRTapeJob 
foreach ($tapeJob in $tapeJobs) {
  if ($tapeJob.Type -eq 'BackupToTape') {
    if ($tapeJob.FullBackupPolicy.Type -eq 'Monthly') {
      $tapeJob | select Name, @{n='FullBackupMediaPool';e={$_.FullBackupMediaPool.Name}}, `
      @{n='FullBackupPolicyType';e={$_.FullBackupPolicy.Type}}, @{n='FullMonthlyOptions';e={$_.FullBackupPolicy.MonthlyOptions}} | fl
    }
    elseif ($tapeJob.FullBackupPolicy.Type -eq 'WeeklyOnDays') {
      $tapeJob | select Name, @{n='FullBackupMediaPool';e={$_.FullBackupMediaPool.Name}}, `
      @{n='FullBackupPolicyType';e={$_.FullBackupPolicy.Type}}, @{n='FullWeeklyOptions';e={$_.FullBackupPolicy.WeeklyOnDays}} | fl
    }
  }
  else {
    if ($tapeJob.FullBackupPolicy.Type -eq 'Monthly') {
      $tapeJob | select Name, @{n='FullBackupMediaPool';e={$_.FullBackupMediaPool.Name}}, `
      @{n='FullBackupPolicyType';e={$_.FullBackupPolicy.Type}}, @{n='FullMonthlyOptions';e={$_.FullBackupPolicy.MonthlyOptions}} | fl
    }
    elseif ($tapeJob.FullBackupPolicy.Type -eq 'Daily') {
      $tapeJob | select Name, @{n='FullBackupMediaPool';e={$_.FullBackupMediaPool.Name}}, `
      @{n='FullBackupPolicyType';e={$_.FullBackupPolicy.Type}}, @{n='FullDailyOptions';e={$_.FullBackupPolicy.DailyOptions}} | fl
    }
    
  }  
}
You can then append Export-Csv to created objects like that to export data to csv:

Code: Select all

  $tapeJob | select Name, FullBackupMediaPool, @{n='FullBackupPolicyType';e={$_.FullBackupPolicy.Type}}, `
  @{n='FullScheduleDays';e={$days}} | Export-Csv
Also, have a look at what Export-Csv cmdlet has to offer if you want to adjust the view of your csv document. -NoTypeInformation parameter is the most commonly used.

Thanks,
Oleg
nunciate
Veteran
Posts: 257
Liked: 40 times
Joined: May 21, 2013 9:08 pm
Full Name: Alan Wells
Contact:

Re: Full Backup Schedule Report

Post by nunciate »

By the way, this worked perfectly for what I needed. Thanks for the help.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests