PowerShell script exchange
Post Reply
daznis
Novice
Posts: 4
Liked: never
Joined: Nov 21, 2023 1:29 pm
Full Name: Darius
Contact:

Script to randomly divide full backups into routhly equal parts.

Post by daznis »

Hello,


I need some help with a script. I'm not a programmer so I can't really lookup what I need. I'm currently trying to divide the load on the storage server. My idea was to divide all Veeam jobs into equal parts by VM size and assign a day when the full backup job can be performed.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Script to randomly divide full backups into routhly equal parts.

Post by oleg.feoktistov » 1 person likes this post

Hi Darius,

I don't quite understand the use case. Can you maybe elaborate more with an example?

Thanks,
Oleg
daznis
Novice
Posts: 4
Liked: never
Joined: Nov 21, 2023 1:29 pm
Full Name: Darius
Contact:

Re: Script to randomly divide full backups into routhly equal parts.

Post by daznis »

Well basically split the full backup jobs into weekdays. That each day would do about equal amount of "reading" based on VM size. I don't know how to explain it in English.
daznis
Novice
Posts: 4
Liked: never
Joined: Nov 21, 2023 1:29 pm
Full Name: Darius
Contact:

Re: Script to randomly divide full backups into routhly equal parts.

Post by daznis »

Basically I did this, but it's not really "random". It mostly works, but I'm getting errors on Jobs that have GFS enabled.
The warning it "WARNING: Enable periodic fulls, or schedule a script to create them."

Do I need to set additional things for them ?

Code: Select all


$jobs = Get-VBRJob | ?{$_.JobType -eq "Backup"} | Sort-Object -Property info.IncludedSize 

$Week = @( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" )

$size = @( 0, 0, 0, 0, 0, 0, 0)

foreach ($job in $jobs) {
    
    $options = Get-VBRJobOptions -Job $job

    $JobSize = $job.info.IncludedSize / 1GB -as [INT]
    
    $min=[int]($size | measure -Minimum).Minimum

    $i = $size.IndexOf($min)

    $size.Item($i) = $size.Item($i) + $JobSize

    $options.GenerationPolicy.EnableRechek = $true
    $options.GenerationPolicy.RecheckScheduleKind = "Daily"
    $options.GenerationPolicy.RecheckDays = $Week[$i]

    Set-VBRJobOptions -job $job -Options $options
    Set-VBRJobAdvancedBackupOptions -Job $job -FullBackupScheduleKind Daily -EnableFullBackup $true -FullBackupDays $Week[$i]
}

for ($i = 0; $i -lt $Week.Length; $i++) {
    write-host 
    Write-host -NoNewline $Week[$i] "Size: " $size[$i] "GB"
} 
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Script to randomly divide full backups into routhly equal parts.

Post by david.domask »

@daznis, can I ask, you want this as a "one-off" script to randomize your full backup schedules or you want it randomized each week?

I'm a bit confused why you have the EnableRecheck section of your code -- that's for HealthCheck.

If you can elaborate what you're trying to accomplish (describe your desired business logic and/or outcome of the script), we can help more.
David Domask | Product Management: Principal Analyst
daznis
Novice
Posts: 4
Liked: never
Joined: Nov 21, 2023 1:29 pm
Full Name: Darius
Contact:

Re: Script to randomly divide full backups into routhly equal parts.

Post by daznis »

@david.domask My Idea was to divide full backups as equally as possible over the week. As most of our backups have either 7 ar 14 day retention. I though that doing a health check before the full backup would eliminate some data inconsistencies. We had some issues with synthetic backups not restoring correctly.
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Script to randomly divide full backups into routhly equal parts.

Post by david.domask »

Got it, that part is clear -- but are you running active fulls or Synthetic fulls? And do you need to adjust the schedule dynamically based on what gets added to the job or this is just something that should run occasionally as you want it?

As I get it, you have several items you're trying to solve:

1. Avoid load on the storage by spreading the full backup days out
2. Do your best to assure no data inconsistencies and also spread health-checks out to avoid load on storage

The health check (HC) isn't a problem for your script I just did not understand if it was important or not for your needs.

@daznis, maybe PM me your full description in your native tongue, I'll understand it enough I'm sure (forums are English only, so let's PM). Right now I'm not sure that a script is what you need but I'm not understanding in full yet ))
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests