Pre job script seems to clear "Advanced" options on Job

PowerShell script exchange

Pre job script seems to clear "Advanced" options on Job

Veeam Logoby MMiller69 » Thu Aug 06, 2015 10:42 am

Hi

In order maintain the backup policies for my company I have had to create pre and post job Powershell scripts for our Veeam jobs.

The pre job script scans the repository for the latest VBK & VBM files, adds them to an Object then dumps that object into the FileBackupToTape jobs. This works great and the backups run fine, however in the process of modifying the job file selections the script somehow also seems to clear out a couple of advanced options, namely post job notifications and Job scripts. Obviously this means that the we don't receive the post job completion mails and the post job scripts don't run.

I do have an active case for this, as I believe it to be a bug, but I thought I would post the script here and see what the community here thought. (obfuscated data in a couple of variables)

Code: Select all
<#
Powershell job seelction script for Veeam Backup
Created by Mark Miller
30/6/2015
#>
add-pssnapin VeeamPSSnapin

$NewFileSelection = @()
$CopyJobs = @()
$JobNamepart = @()
$fileSelection = @()
$Size = 0

$dir = "\\<servername>\d$\Backups" # One script per respoitory
$path = "d:\Backups"
$Server = Get-VBRServer | Where {$_.Name -eq "<servername>"} # Gets the servername
$VBRJob = Get-VBRtapeJob | ? {$_.name -eq "Monthly File Backup Repository 1"} # Select target Backup to Tap job

$mailTo = "<destination mail address>"
$mailFrom = "<Source mail address>"
$smtpServer = "<mail server>"
$Subject = "Monthly Veeam Backup to Tape of Repository 1"

$filetypes = @("*.vbk","*.vbm")

$jobFolders = Get-ChildItem -Recurse -path $dir | ?{ $_.PSIsContainer }
 foreach ($f in $jobFolders){
  foreach ($ft in $filetypes){
   $latestVBK = Get-ChildItem -path $f.FullName -filter $ft | Sort-Object LastAccessTime -Descending | select-object -first 1
        if ($latestVBK -ne $null){
             $fileSelection += ($latestVBK.FullName).Replace($dir,$path)
             $size += $latestVBK.Length
        } 
      }
 }
 foreach ($fs in $fileSelection){
     $newfileselection += New-VBRFiletoTapeObject -Server $server -Path $fs #Build file selection list
        if ($fs -like "*copy*"){
       
        $JobNamepart += $fs.Split("\")[2]
        }
     }

$JobNamepart = $JobNamepart | sort -Unique
$s = "{0:N2}" -f ($size / 1tb)   
$data = $NewFileSelection.path + "Backup Size (TB): $s" | fl | Out-String

Send-MailMessage -From $mailFrom -To $mailTo -Subject "Monthly File Backup Repository 1 Script" -SmtpServer $smtpServer  $Data

Set-VBRFileToTapeJob -Job $VBRJob.ID -Object $NewFileSelection # Writes selection list to target job
Disable-VBRJob -Job $JobNamepart

MMiller69
Novice
 
Posts: 3
Liked: 1 time
Joined: Mon May 19, 2014 9:12 am
Full Name: Mark Miller

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby PTide » Thu Aug 06, 2015 2:12 pm

Hi,

Such behaviour is unexpected. As reference says:
The parameters that you omit will remain unchanged.


Please open the case with support.

Thank you.
PTide
Veeam Software
 
Posts: 3022
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby MMiller69 » Thu Aug 06, 2015 2:34 pm

Hi

Exactly as I thought, which is why I opened a case with support, although it took a little bit of convincing for them to open one :)
MMiller69
Novice
 
Posts: 3
Liked: 1 time
Joined: Mon May 19, 2014 9:12 am
Full Name: Mark Miller

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby v.Eremin » Tue Aug 11, 2015 5:19 pm

I've just tested that, and it seems that the said commandlet resets advanced settings, indeed. Looks like a bug.

I've passed this information to the dev.team. So, thank you for the feedback; much appreciated.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13288
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby MMiller69 » Fri Aug 21, 2015 2:16 pm 1 person likes this post

Hi

Just had it confirmed now from support team & QA department that's this is indeed a bug, and that it will be fixed in v9.

However obviously this mean that at this time those of us on v8 will not be able to use the cmdlet in a pre-job script without messing up the advanced options. Hoping that some workaround can be produced.
MMiller69
Novice
 
Posts: 3
Liked: 1 time
Joined: Mon May 19, 2014 9:12 am
Full Name: Mark Miller

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby v.Eremin » Fri Aug 21, 2015 3:51 pm

As those advanced settings are not currently configurable via PowerShell, I don't think a workaround can be created that easily. Thanks.
v.Eremin
Veeam Software
 
Posts: 13288
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby winnt » Wed Dec 16, 2015 4:32 pm

I have the same issue. Has anyone found a workaround? Thanks.
winnt
Influencer
 
Posts: 15
Liked: 7 times
Joined: Fri Apr 03, 2015 9:19 pm
Full Name: J D

Re: Pre job script seems to clear "Advanced" options on Job

Veeam Logoby v.Eremin » Wed Dec 16, 2015 5:34 pm

I've just checked and the said bug seems to be addressed in version 9. Thanks.
v.Eremin
Veeam Software
 
Posts: 13288
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: m.lazzarotto, Yahoo [Bot] and 3 guests