PowerShell script exchange
Post Reply
rbbch
Influencer
Posts: 18
Liked: never
Joined: Mar 16, 2022 12:44 pm
Full Name: Ben Curtis-Haigh
Contact:

Backup Mode Switch

Post by rbbch »

Hello,

I am looking to transition from Reverse Incremental to Forever Forward Incremental. We have a large number of jobs though, so this will take me ages. Does anyone have a script to show the backup mode for each job and then change the backup mode?

Thanks for any help in advance!

Kind Regards
Ben
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Backup Mode Switch

Post by oleg.feoktistov »

Hi Ben,

I think the most basic script would look like that:

Code: Select all

$jobs = Get-VBRJob
$jobsReport = @()
foreach ($job in $jobs) {
if ($job.BackupTargetOptions.Algorithm -eq 'Syntethic') {
 $backupMode = 'ReverseIncrement'
}
elseif ($job.BackupTargetOptions.Algorithm -eq 'Increment') {
 $backupMode = 'Increment'
}

elseif ($job.BackupTargetOptions.Algorithm -eq 'Full') {
 $backupMode = 'Increment'
}

elseif ($job.BackupTargetOptions.Algorithm -eq 'Transform') {
 $backupMode = 'Increment'
}
elseif ($job.BackupTargetOptions.Algorithm -eq 'TransformForeverIncremental') {
 $backupMode = 'Increment'
}
$jobsReport += $job | select Id, Name, @{n='BackupMode';e={$backupMode}}

}

$jobsReport | Format-Table

Start-Sleep -Seconds 5

foreach ($job in $jobsReport) {
if ($job.BackupMode -eq 'ReverseIncrement') {
  Write-Host "Changing backup mode to incremental for job: $($job.Name)" -ForegroundColor Yellow
  $jobObject = $jobs | where {$_.Id -eq $job.Id}
  $options = Get-VBRJobOptions -Job $jobObject
  $options.BackupTargetOptions.Algorithm = 'Increment'
  $options.BackupTargetOptions.TransformFullToSyntethic = $false
  Set-VBRJobOptions -Job $jobObject -Options $options | Out-Null
 }
}

It goes exactly as you say. First it outputs a job list with the corresponding backup modes. Then it checks whether the backup mode is reverse incremental and changes it to forward incremental if it is.

Few notes from my side:

1. Though backup mode relies on Algorithm property in the very backend code of the job class, values there don't correspond to what you can see in the UI. That being said, 'Syntethic' value actually controls reverse incremental type, whereas all other types control forward incremental type (I know, such legacy backend code we are tied to can be very confusing). For that reason I used so many validations to bring it all to a binary reverse/forward incremental logic.

2. Since you mentioned forever forward incremental type, I also added the line below to the script so that synthetic fulls are not enabled automatically when you switch from reverse incremental:

Code: Select all

    $options.BackupTargetOptions.TransformFullToSyntethic = $false
    
Best regards,
Oleg
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Backup Mode Switch

Post by oleg.feoktistov »

Another thing. I would recommend filtering jobs beforehand to just those of Backup type so that you don't amend backend code of the jobs that don't support backup mode change. Not that it seem to impact these jobs upon script execution, but we are working with a legacy class in a legacy way. So just to be a bit safer here.

Code: Select all

$jobs = Get-VBRJob | where {$_.JobType -eq 'Backup'}
Thanks!
rbbch
Influencer
Posts: 18
Liked: never
Joined: Mar 16, 2022 12:44 pm
Full Name: Ben Curtis-Haigh
Contact:

Re: Backup Mode Switch

Post by rbbch »

Does this only affect the reverse incremental backup modes. We have a few that are incremental with synthetic fulls which I would like to stay as is.

Also, to confirm, when you say Forward Incremental do you mean, FFI?

Thanks so much!!!
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Backup Mode Switch

Post by oleg.feoktistov »

Yes, it does affect reverse incremental jobs only. I understand, it might be confusing, because the values are really different from what you see in the UI.
But before executing the script I encourage you to get algorithm values for a single backup job with reverse incremental mode, for instance, with the code below, change backup mode in the UI to forward incremental and invoke the script once again to see what I mean:

Code: Select all

$jobs = Get-VBRJob -Name 'Backup Job 1'
foreach ($job in $jobs) {
  $job | select Id, Name, @{n='Algorithm';e={$_.BackupTargetOptions.Algorithm}}, `
  @{n='SyntheticFullsEnabled';e={$_.BackupTargetOptions.TransformFullToSyntethic}} | fl
}
Note that when you invoke this script on a job in incremental backup mode with synth fulls enabled, then change backup mode to reverse incremental without unticking synth fulls box and invoke the script again, you will see that in the script output synth full is still enabled for this job. But in the UI the synth full option is greyed out because the mode was changed to reverse incremental. It is a very confusing discrepancy, but it basically means that synth fulls are disabled because reverse incremental mode is in place.
Also, to confirm, when you say Forward Incremental do you mean, FFI?
Yes, that is why I also added the line to the script that disables synth full option.

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests