Create Backup Job from VM folders

PowerShell script exchange

Create Backup Job from VM folders

Veeam Logoby oli4 » Wed Aug 26, 2015 9:59 am

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
oli4
Enthusiast
 
Posts: 38
Liked: 2 times
Joined: Tue Aug 14, 2012 11:34 am

Re: Create Backup Job from VM folders

Veeam Logoby v.Eremin » Wed Aug 26, 2015 1:08 pm

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Create Backup Job from VM folders

Veeam Logoby oli4 » Thu Aug 27, 2015 12:26 pm

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".
oli4
Enthusiast
 
Posts: 38
Liked: 2 times
Joined: Tue Aug 14, 2012 11:34 am

Re: Create Backup Job from VM folders

Veeam Logoby v.Eremin » Thu Aug 27, 2015 12:32 pm

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Create Backup Job from VM folders

Veeam Logoby oli4 » Thu Aug 27, 2015 12:39 pm

I tried it with that easy one:

$Folder = "Testfolder"
Add-VBRViBackupJob -Name "Testjob" -Entity $Folder
oli4
Enthusiast
 
Posts: 38
Liked: 2 times
Joined: Tue Aug 14, 2012 11:34 am

Re: Create Backup Job from VM folders

Veeam Logoby v.Eremin » Thu Aug 27, 2015 12:52 pm

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Create Backup Job from VM folders

Veeam Logoby oli4 » Thu Aug 27, 2015 1:00 pm

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
    }
oli4
Enthusiast
 
Posts: 38
Liked: 2 times
Joined: Tue Aug 14, 2012 11:34 am

Re: Create Backup Job from VM folders

Veeam Logoby v.Eremin » Thu Aug 27, 2015 1:03 pm

$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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Create Backup Job from VM folders

Veeam Logoby oli4 » Thu Aug 27, 2015 1:25 pm 1 person likes this post

OK, thanks, now it works.
oli4
Enthusiast
 
Posts: 38
Liked: 2 times
Joined: Tue Aug 14, 2012 11:34 am

Re: Create Backup Job from VM folders

Veeam Logoby v.Eremin » Thu Aug 27, 2015 1:41 pm

You're welcome. Feel free to reach us, if other help is needed. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: Google [Bot] and 4 guests