PowerShell script exchange
Post Reply
Ahmed.albatoosh
Lurker
Posts: 2
Liked: never
Joined: Oct 22, 2023 8:08 am
Full Name: Ahmed Hasan Salman
Contact:

change repo by Power Shell

Post by Ahmed.albatoosh »

You have 70 File Share backup jobs in Veeam, and you want to change their repository destination (all to a new repo) in one go without manually editing every job.
This can’t be done from the GUI in one click, but you can automate it using PowerShell with Veeam’s snap-in.

can one assistance for code
david.domask
Veeam Software
Posts: 2931
Liked: 674 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: change repo by Power Shell

Post by david.domask »

Hi Ahmed.albatoosh,

Sure, the following code is pseudo-code, but should be all you need:

cmdlets:

Get-VBRUnstructuredBackupJob
Get-VBRUnstructuredBackup
Detach-VBRBackup
Set-VBRNasBackupJob

Basic workflow would be:

Code: Select all

$uJob = Get-VBRUnstructuredBackupJob #Fetches all Unstructured backup jobs, probably you will want to filter this somehow
$newRepo = Get-VBRBackupRepository -Name "Name of new Repository"
Foreach($u in $uJob){
	$uBackup = Get-VBRUnstructuredBackup | Where-Object {$_.JobId -eq $u.id}
	Detach-VBRBackup -Backup $uBackup
	Set-VBRNasBackupJob -Job $u -ShortTermBackupRepository $newRepo
	Delete-Variable ubackup
}
Note this is very basic structure of the code and will point all jobs to the repo you assign to variable $newRepo -- if you need to point to different repositories depending on the job, you will need to write your own logic to determine that.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest