PowerShell script exchange
Post Reply
jnap
Enthusiast
Posts: 56
Liked: 4 times
Joined: Feb 11, 2020 4:54 pm
Contact:

how to add a new nas share into a nas backup job

Post by jnap »

Hello,

I have a nas backup job, and i want to add a new share into this job, without modifying anything else into the job (parameters, shares,...)

I try this one:

Code: Select all

$job = Get-VBRNASBackupJob -name NASBKPJOB
$server = Get-VBRNASServer -Name \\my\share
New-VBRNASBackupJobObject -Server $server
$object = New-VBRNASBackupJobObject -Server $server
Set-VBRNASBackupJob -Job $job -BackupObject $object
but when i did that, the share "\\my\share" replace the shares that were already into the job

How can i just add it and not replace?
With the console, it is just one click on the share into inventory/file shares :)
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: how to add a new nas share into a nas backup job

Post by oleg.feoktistov »

Hi @jnap,

You need to get the existing job with all its backup objects first and then operate a little on them to make it work. I described all the steps as comments in the example below:

Code: Select all

# Get existing NAS Backup Job, all its objects and create a new array out of range of backed up NAS servers
$nasJob = Get-VBRNASBackupJob
$jobObjects = $nasJob.BackupObject
$nasJobServers = @()
foreach ($object in $jobObjects) {
    $nasJobServers += $object.Server
}

# Get existing NAS server you want to add to the job and add it to the array of NAS servers you obtained from the existing job
$nasServer = Get-VBRNASServer -Name '*localhost*'
$nasJobServers += $nasServer

# Construct a new NAS Backup Job Objects array out of the array of NAS servers you created above
$newNasObjects = @() 
foreach ($server in $nasJobServers) {
  $nasObject = New-VBRNASBackupJobObject -Server $server -Path $server.Path
  $newNasObjects += $nasObject
}

# Pass the array of created NAS Backup Objects to the NAS Backup Job
Set-VBRNASBackupJob -Job $nasJob -BackupObject $newNasObjects 

Hope it helps,
Oleg
jnap
Enthusiast
Posts: 56
Liked: 4 times
Joined: Feb 11, 2020 4:54 pm
Contact:

Re: how to add a new nas share into a nas backup job

Post by jnap »

Yes it helps!

Thanks ! :)
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests