Working with the Veeam Powershell toolkit


After the short introduction of the Veeam Powershell toolkit in my earlier post, It was about time to play with the Toolkit. In this post I will show you how to create a Backup Job and how to add VM’s to the backup job.

Lets start to add a new Veeam and Replication backup job called “Production” and add the following VM’s: DC01, VC01 and MC01:

$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"}
$vbrjobname = "Production"
$vbrfolder = "C:\veeam\production\"
$vbrfile = "production.vbk"
$vbrobjects = "DC01","VC01","MC01"

Add-VBRBackupJob -Name $vbrjobname -Type VDDK -Server $vbrserver `
-Folder $vbrfolder -FileName $vbrfile -Objects $vbrobjects

The backup job is created and the following output will be generated on the console:

image

You can verify the Job settings and the selected VM’s inside the GUI:

image

If you want to add an extra VM to the backup job. You can run the following code to add a VM called NAGIOS:

$vbrjobname = "Production"
$vbrjob = Get-VBRJob | Where {$_.Name -eq $vbrjobname}
$vbrserver = Get-VBRServer | Where {$_.Type -eq "VC"}
$vbrobjects = "NAGIOS"

Add-VBRJobObject -Job $vbrjob -Server $vbrserver -Object $vbrobjects

Annotation: the $vbrserver parameter is different than the first script in this post. When you want to add an Object to an existing job, you need to use the vCenter server as the backup source instead of the Veeam Backup server because you need to add an object from vCenter server to the backup job. See help for more info:

get-help Add-VBRJobObject -Detailed

The output from the command:

NAME

    Add-VBRJobObject

SYNOPSIS

    Add VMs or VM containers to the existing job.

SYNTAX

    Add-VBRJobObject [-Job] <CBackupJob> [-Server] <CHost> [-Objects] <String[]

    > [-WarningAction <ActionPreference>] [-WarningVariable <String>] [<CommonP

    arameters>]

    Add-VBRJobObject [-Job] <CBackupJob> [-Server] <CHost> [-Entities] <CEntity

    []> [-WarningAction <ActionPreference>] [-WarningVariable <String>] [<Commo

    nParameters>]

DESCRIPTION

    Add VMs or VM containers to the existing backup, replication or copy job.

PARAMETERS

    -Job <CBackupJob>

        Provide an object of the existing backup, replication or copy job.

    -Server <CHost>

        Provide an object of the ESX/ESXi server on which VMs or VM containers

        reside.

    -Objects <String[]>

        Provide objects of VMs or containers of VMs that you want to back up, r

        eplicate or copy.

When the command completed successfully you will see the following output:

image

To be continued…

Advertisements

2 thoughts on “Working with the Veeam Powershell toolkit

  1. Alex

    Hi, I’m trying to add an exclusion with powershell to an existing veeam job. Adding is no problem but it says type is included and no luck so far getting it to excluded. Do you have any suggestions?

    Reply
    1. Bob

      Use Remove-vbrJobObject :

      $Job = Get-vbrJob | Where {$_.Name -eq “Veeam Backup Job Name”}

      Remove-vbrJobObject -job $Job -Objects (Get-vbrJobObject -job $Job | Where {$_.Name -eq “VM-To-Exclude”})

      The VM will show up as ‘Included’ and ‘Excluded’ which takes precedence.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s