Veeam Powershell Automatically Add Backup Jobs

0

One of the great things with Veeam Backup & Replication is the integration with PowerShell and the ability to automate many of the job options using PowerShell.  This is extremely handy when it comes to mass creating Veeam jobs in your environment by simply being able to query a list of VMs from vCenter, etc.  Recently, I had to throw together a script to create Veeam jobs quickly in an environment using PowerShell.  Let’s take a look at how to with Veeam PowerShell automatically add backup jobs.

veeamposh01 Veeam Powershell Automatically Add Backup Jobs

Veeam Powershell Automatically Add Backup Jobs

There are several commandlets we can utilize to get the VMs from our VMware environment over to our Veeam backup environment.  We can utilize the following Veeam commandlets to query and create the jobs:

Let’s look at the PowerShell Code block:

In the above, we get the list of VMs from a get-content read of a text file.  This provides the list of VMs that we want to actually create the jobs for.  We set a variable to get the encryption key for easy usage.

Now we actually start looping through the VMs.  We use the Find-VBRViEntity to find the name of the VM in our vSphere environment.  Then for this VM, we use the Add-VBRViBackupJob commandlet to create the job based on the name of the VM.  Here I am appending the “_new” to the name for a special use case.  For most you may not want to append anything.  With the Set-VBRJobSchedule we set the job schedule parameters.  Here I am setting the schedule to backup the VM every hour.

In the final section of the block, since there isn’t a Veeam PowerShell commandlet for this purpose (that I could find), I am using this chunk of code to set the number of Retension points that we want to keep for each job.

Finally, we log the results to a variable if we want to use this or simply create the log file.

Thoughts

The above is certainly a gorilla script without much time for commenting or any other creative work, however, we can see the power of using Veeam Powershell Automatically Add Backup Jobs to our environment and change settings of these on the fly as they are created.  This is a much easier way of creating multiple jobs than using the wizard for each individual one. [jetpack-related-posts]