PowerShell script exchange
Post Reply
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Update repos on multiple jobs

Post by Kazz »

Hi,

I am hosting 4 repos on a physical box with directly attached storage. One of the PSU on the server has failed (server is out of warranty) and I am not going to purchase a new PSU. I have a brand new server where I can move the card and have all disks with repos added back. (In the process of doing it already as I am typing this post).
Repos (das-071-vol01), (das-071-vol02), (das-071-vol03), (das-071-vol04) are distributed between 72 backup jobs.
As I am done adding storage to the new server I will add new repos and point them to the existing backups. Since I would like to update all of my backup jobs with a powershell script, I can’t use the same names for the repos, new repo names in Veeam are gonna be (das-072-vol01), (das-072-vol02), (das-072-vol03), (das-072-vol04).
Here is the question.

Could someone provide a script or point me at some samples of the existing script that can update the repositories on all back up jobs using the following mapping das-071-vol01 = das-072-vol01, das-071-vol02 = das-072-vol02.....

Would I need to do anything else in Veeam once all jobs are updated to point to the new repos or Veeam would be able to continue using the restore points created previously?

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

Re: Update repos on multiple jobs

Post by oleg.feoktistov »

Hi,

Could you please elaborate on the platforms you backup (Virtual: VMware, Hyper-V, physical: agents etc.) and job types you use (backup, backup copy) ? Depending on this, approaches to changing target repositories may vary.

Best regards,
Oleg
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Re: Update repos on multiple jobs

Post by Kazz »

It's VMWare. All jobs are backups.

Code: Select all

$oldRepositoryName = "das-071-vol01"
$newRepositoryName = "das-072-vol01"

# Get a list of all backup jobs
$backupJobs = Get-VBRJob

# Iterate through each backup job
foreach ($job in $backupJobs) {
    # Check if the job uses the old repository
    if ($job.GetOptions().BackupRepository.Name -eq $oldRepositoryName) {
        # Change the repository to the new repository
        $jobOptions = $job.GetOptions()
        $jobOptions.BackupRepository = Get-VBRBackupRepository -Name $newRepositoryName

        # Save the changes to the job
        $job.SetOptions($jobOptions)

        Write-Host "Changed repository for job $($job.Name) from $oldRepositoryName to $newRepositoryName"
    }
}
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Update repos on multiple jobs

Post by oleg.feoktistov »

Unfortunately, we don't have an official cmdlet to modify VMware backup jobs without using .NET. And the workaround you are using right now is not reliable. In v12.1 the property you are setting in job options is not there already. A repository is being setup through the method, which doesn't take into account the options that you must choose between in the UI whenever a backup is present and you need to change a target repository - to move existing backups to a new target repository or just detach them from and start a new backup chain on a new target repository. Having tried this method, I can see that it actually breaks the job.

However, we do have the rest api call that allows to modify target repositories for vmware backup jobs (starts a new backup chain on a new target repository only).

Would you consider using it instead?


Best regards,
Oleg
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Re: Update repos on multiple jobs

Post by Kazz »

Got it, I can confirm that the script I shared runs without any errors, but does not make any changes.

Is there a way to update the proxy servers on multiple jobs? I will start a new thread with explanation of what I need to accomplish.
The problem I am running in to is I am overwriting all proxies currently selected for the job and I need to preserve existing proxies except for the proxy that was taken offline
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests