PowerShell script exchange
Post Reply
oli4
Enthusiast
Posts: 63
Liked: 3 times
Joined: Aug 14, 2012 11:34 am
Contact:

Create Backup Job from VM folders

Post by oli4 »

Hello

is there an easy way to create with powershell a backup job for each VM folder from VMware vCenter?
With Add-VBRViBackupJob I can only specify an "Entity", means a VM.

Regards
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Backup Job from VM folders

Post by veremin » 1 person likes this post

Entity parameter accepts folder item, as well. I've just created a job with a folder as a source, using the following script:

Code: Select all

$Server = Get-VBRServer -Name "Name of your vCenter"
$Folder = Find-VBRViEntity -Server $Server -name "Name of your folder"| where {$_.type -eq "Folder"}
$Repository = Get-VBRBackupRepository -Name "Name of your repository"
Add-VBRViBackupJob -Name "Test Job" -BackupRepository $Repository -Entity $Folder
Thanks.
oli4
Enthusiast
Posts: 63
Liked: 3 times
Joined: Aug 14, 2012 11:34 am
Contact:

Re: Create Backup Job from VM folders

Post by oli4 »

Hi Vladimir, my script looks almost the same, but when I try your (or my) script I get the message:

Add-VBRViBackupJob : Cannot bind parameter 'Entity'. Cannot convert the "Testfolder" value of type "System.String" to type "Veeam.Backup.Core.Infrastructure.IViItem".
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Backup Job from VM folders

Post by veremin »

Can you provide me with the script you've created? It looks like the way you get a folder entity might be slightly wrong. Thanks.
oli4
Enthusiast
Posts: 63
Liked: 3 times
Joined: Aug 14, 2012 11:34 am
Contact:

Re: Create Backup Job from VM folders

Post by oli4 »

I tried it with that easy one:

$Folder = "Testfolder"
Add-VBRViBackupJob -Name "Testjob" -Entity $Folder
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Backup Job from VM folders

Post by veremin »

So, that is the problem. In the example provided by you $Folder variable contains string value "Testfolder", not the ViItem that is expected by -Entity parameter.

Try the script I've mentioned, replacing "Name of your folder" with the name of folder you want to backup.

Thanks.
oli4
Enthusiast
Posts: 63
Liked: 3 times
Joined: Aug 14, 2012 11:34 am
Contact:

Re: Create Backup Job from VM folders

Post by oli4 »

I dont see the difference, my original script is:

Code: Select all

$vCenter = "<vCenter Name>"
$VeeamFolders = Find-VBRViFolder -Server $vCenter -Name "*-BKP*"

ForEach($V in $VeeamFolders)
    {
    Add-VBRViBackupJob -Name $V.Name -Entity $V.Name
    }
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Backup Job from VM folders

Post by veremin »

$V.Name is a string containing name of a folder, not a folder object itself. That's the difference.

In order for your script to work properly, it should be changed:

Code: Select all

    $vCenter = "<vCenter Name>"
    $VeeamFolders = Find-VBRViFolder -Server $vCenter -Name "*-BKP*"

    ForEach($V in $VeeamFolders)
        {
        Add-VBRViBackupJob -Name $V.Name -Entity $V
        }
Thanks.
oli4
Enthusiast
Posts: 63
Liked: 3 times
Joined: Aug 14, 2012 11:34 am
Contact:

Re: Create Backup Job from VM folders

Post by oli4 » 1 person likes this post

OK, thanks, now it works.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Create Backup Job from VM folders

Post by veremin »

You're welcome. Feel free to reach us, if other help is needed. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests