PowerShell script exchange
Post Reply
nd39475
Enthusiast
Posts: 61
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Problems with Add-VBRCopyJob

Post by nd39475 »

does this sound familiar? i searched the subject first and found other threads.

i want to iterate all my jobs and create copy-jobs based on them, but run into issue right off the bat. Add-VBRCopyJob has a -Type parameter of which i expect to accept "BackupSync", because that is what Get-VBRJob reported to me on a test-copy-job. However it does not. Additionally, the reference document reports that the "Backup" type is "not supported (legacy mode)". So how can this cmdlet even be used?

Furthermore why do Veaam powershell cmdlets not have the -WhatIf parameter?

This, (Veeam cmdlets), could be a god-send, but each and every time i get into a session i'm presented with more weird issues than i'd expect. I've used Powershell for AD and Powershell for VMware with much less aggravation. just IMHO. thanks for the rant relief.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Problems with Add-VBRCopyJob

Post by jhoughes » 1 person likes this post

You should be using either Add-VBRViBackupCopyJob or Add-VBRHvBackupCopyJob, depending on which type of environment you have.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
nd39475
Enthusiast
Posts: 61
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: Problems with Add-VBRCopyJob

Post by nd39475 »

wow, thank you. world of difference! i guess apologies are in order ;P
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Problems with Add-VBRCopyJob

Post by jhoughes »

No worries, I'll check if we should move it to the obsolete cmdlets within the documentation.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
nd39475
Enthusiast
Posts: 61
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: Problems with Add-VBRCopyJob

Post by nd39475 »

Well i got it good enough for me, but not perfect, i tried getting some advanced schedules working, but gave up.

My simplified script is as follows just to get the jobs running with simplerestorepoints. i can do the rest manually via GUI.

Code: Select all

Add-PSSnapin VeeamPSSnapIn
$Testing = $true

Disconnect-VBRServer
Connect-VBRServer -server "veeam-serv" -port 9392

$TargetVeeamRepo = "Library BackupRepo 62TB"

$jobs = ( Get-VBRJob | Where-Object {$_.Name -notlike "*Library*" -and $_.Name -notlike "*Off*Campus*" -and $_.Name -notlike "*Copy*"} | Sort-Object -Property Name)
#$jobs = ( Get-VBRJob | Where-Object {$_.Name -eq "TESTJob"} | Sort-Object -Property Name)

foreach ($job in $jobs) {
  $jName = $job.Name
  $NewCopyJobName = "Library2 $jName BackupCopy"
  Write-Host "Job: $jName --> $NewCopyJobName"
  If (!$testing) {
    Write-Host "Adding: BackupCopyJob named `"$NewCopyJobName`" to `"$TargetVeeamRepo`"."
    Add-VBRViBackupCopyJob -DirectOperation -Name "$NewCopyJobName" -Backup "$jName" -Repository "$TargetVeeamRepo"
    
    $copyJob = Get-VBRJob -Name "$NewCopyJobName"
    $Options = $copyJob.GetOptions()
    $Options.GenerationPolicy.SimpleRetentionRestorePoints = 61
    Set-VBRJobOptions -Job "$NewCopyJobName" -Options $Options
  } else {
    Write-Host "Testing: Nothing being done for: BackupCopyJob named `"$NewCopyJobName`". Set`$Testing=`$false for action."
  }

}
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Problems with Add-VBRCopyJob

Post by veremin »

nd39475 wrote:Well i got it good enough for me, but not perfect, i tried getting some advanced schedules working, but gave up.
Can you tell me what exact settings you're struggling with? Chances are, they can be easily changed (via get/setoptions()) after job creation. Thanks!
nd39475
Enthusiast
Posts: 61
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: Problems with Add-VBRCopyJob

Post by nd39475 »

i wanted to set target's periodical fulls as follows:

Code: Select all

[✓] Keep the following restore points as full backups for archival purposes
  Weekly backup: [0]
  Monthly backup [1]
TY
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Problems with Add-VBRCopyJob

Post by veremin »

Check the GenerationPolicy set of options of the already created jobs. It should have everything you need (the parameter names are self-explanatory). Thanks!
nd39475
Enthusiast
Posts: 61
Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:

Re: Problems with Add-VBRCopyJob

Post by nd39475 »

Thank you so much!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests