This Site Is Depreciated
  • This is the depreciated Version of Veeam Backup & Replication Best Practices
  • Contacting Veeam Software
  • DNS Resolution
  • Veeam Backup Server
    • Deployment Method
    • Backup Server Placement
    • Sizing and System Requirements
    • Veeam Backup & Replication Database
    • Protecting Veeam Backup & Replication Configuration
  • Veeam Enterprise Manager
    • vCloud Director Self Service Portal
  • Search Server and Indexing
  • Proxy Servers - Introduction
    • Proxy - VMware vSphere
      • Transport Modes
        • Direct Storage Access
        • Virtual Appliance Mode
        • Network Mode
        • Backup from Storage Snapshots
          • NetApp Data ONTAP integration
          • Nimble Storage integration
        • Selecting a Transport Mode
      • Sizing a Backup Proxy
    • Proxy - Microsoft Hyper-V
    • Proxy - Nutanix AHV
  • Primary and secondary Storage BPs
    • HPE 3PAR VMs disks considerations
    • DellEMC Data Domain advanced scalability
  • Backup Repository
    • Repository Types
      • SMB
      • Deduplication Appliances
      • Integration specifics
      • Windows Server Deduplication
      • Object Storage
    • Repository Planning
      • Sizing
      • Per VM Backup Files
      • Scale-out Backup Repository
        • Capacity Tier
    • Repository HA
  • WAN Acceleration
    • Analyzing Wan Acceleration Workload
    • Comparing WAN Acceleration Modes
    • Sizing For WAN Acceleration
    • Sizing Targets for WAN Accereration Relationship
    • Deployments For WAN Acceleration
    • Is WAN Acceleration Right For me
  • Tape Support
    • Tape Deployments
    • Tape Media Information
    • Tape Config Requirements
    • Tape Parallel Processing
    • Tape Virtual Full
    • Tape Writing to Tape
    • Tape Restores
  • Veeam Explorers
  • Interaction with VMware vSphere
  • Interaction with Microsoft Hyper-V
  • Job Configuration
    • Backup Methods
    • Encryption
    • Deduplication and Compression
    • Backup Job
    • Backup Copy Job
    • Replication Job
    • Application-Aware Image Processing
  • Data Verification Using Virtual Labs
  • Overview of Applications Support
    • Active Directory
    • Microsoft Exchange
    • Microsoft SQL Server
    • Microsoft SharePoint Server
    • Oracle Database
    • MySQL
    • IBM Notes/Domino
    • SAP HANA
  • POC Guide
    • Assessment
    • Accelerated Evaluation
    • Enhanced Evaluation
      • Workshop Example
      • Preparation
      • Automation
  • Infrastructure Hardening
    • Segmentation using Zones
    • Hardening Backup Repository - Linux
    • Hardening Backup Repository - Windows
  • Backup & Replication Anatomy
    • Backup
    • VM Restore
    • Instant VM Recovery
    • Windows File-Level Restore
    • Replication
  • Networking Diagrams
    • Backup Server
    • Proxy Server
    • Repository Server
    • Storage Integration
    • Data Validation
  • Application-aware Image Processing
  • Enterprise Manager
  • Sizing Summary
Powered by GitBook
On this page
  • Command line
  • PowerShell
  • RESTful API
  • A simple RESTful API example - adding a guest to a backup job
  • Authentication on the REST server
  • Building a query to retrieve the vCenter UID
  • Building a lookup to retrieve the virtual machine ID
  • Building a query to retrieve the Job ID
  • Adding the VM to the job
  • Closing the connection

Was this helpful?

  1. POC Guide
  2. Enhanced Evaluation

Automation

PreviousPreparationNextInfrastructure Hardening

Last updated 4 years ago

Was this helpful?

The bigger the environment, the more automation is needed to reduce the administration effort. For example, if you are operating 40 branch offices with independent Veeam installations, you may want to roll out and configure backup servers with scripts, and automatically create jobs in the same location. Another example is automatic job creation for 2,000-3,000 VMs with exactly the same configurations, which can limit user-caused misconfiguration.

Command line

Following operations are managed through the Windows command line:

  • Installation -

  • Updates -

PowerShell

Operations in Veeam Backup & Replication can be automated with Veeam PowerShell snap-in in the following areas:

  • Configuration

  • Job creation/job editing

  • Working with external schedulers (UC4/TWS and other) to start Veeam jobs

  • Restores

  • Reporting

  • Datacenter migration (quick migration or replication)

The PowerShell plugin is available with all commercial versions of the product.

Note: PowerShell plugin is also available with Veeam Backup FREE, although limited:

Our customers and partners use this functionality to scale out backup infrastructure environments to nearly 100,000 VMs under a single Veeam Backup Enterprise Manager instance with multiple backup servers located in different datacenters.

RESTful API

In the Veeam Enterprise Manager, there is as well RESTful API that allows you to create workflows in orchestration tools or to integrate Veeam Backup Enterprise Manager (self-services) in your own “cloud” portal. Specifically, this is an option that comes with Enterprise Plus Editions and is focused on the hosting business.

Here is a list of external resources:

A simple RESTful API example - adding a guest to a backup job

In the following section, the Veeam WEB client will be used for convenience as it is quite simple by nature and instantly available through enterprise manager URL. Also, the browser used is configured to accept cookies to simplify the authentication token management.

Authentication on the REST server

Building a query to retrieve the vCenter UID

Once logged in, knowing the vCenter Name where the VM we want to add resides, we need to get the vCenter UID.

  • Object type is “ManagedServer”

  • Property to filter is “ManagedServerType” from which “VC” corresponds to vCenter

  • Property to filter is “Name” equal to “vc.democenter.int” in this example

Note: the “ManagedServerType” has been added to the query for demonstration purpose.

<?xml version="1.0" encoding="UTF-8"?>
<QueryResult xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Refs>
    <Ref UID="urn:veeam:ManagedServer:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd" Name="vcsa.democenter.int" Href="http://hq-vbrem1.democenter.int:9399/api/managedServers/93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd" Type="ManagedServerReference">
      <Links>
        <Link Href="http://hq-vbrem1.democenter.int:9399/api/managedServers/93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd?format=Entity" Name="vcsa.democenter.int" Type="ManagedServer" Rel="Alternate"/>
        <Link Href="http://hq-vbrem1.democenter.int:9399/api/backupServers/d7b8bcdd-dbc5-40a3-9a50-dd8ba65cfa91" Name="hq-vbr1.democenter.int" Type="BackupServerReference" Rel="Up"/>
      </Links>
    </Ref>
  </Refs>
  <PagingInfo PageNum="1" PageSize="100" PagesCount="1">
    <Links>
      <Link Href="http://hq-vbrem1.democenter.int:9399/api/query?type=ManagedServer&filter=(ManagedServerType%3d%3dVC%3bName%3d%3d%22vcsa.democenter.int%22)&pageSize=100&page=1" Rel="First"/>
      <Link Href="http://hq-vbrem1.democenter.int:9399/api/query?type=ManagedServer&filter=(ManagedServerType%3d%3dVC%3bName%3d%3d%22vcsa.democenter.int%22)&pageSize=100&page=1" Rel="Last"/>
    </Links>
  </PagingInfo>
</QueryResult>

From here, send a GET request to the HierarchyRoot resource representation to pick up its UID (simply clicking on the URL will send the GET request).

<?xml version="1.0" encoding="UTF-8"?>
<HierarchyRoot Href="http://hq-vbrem1.democenter.int:9399/api/hierarchyRoots/93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd?format=Entity" Type="HierarchyRoot" Name="vcsa.democenter.int" UID="urn:veeam:HierarchyRoot:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Links>
    <Link Href="http://hq-vbrem1.democenter.int:9399/api/backupServers/d7b8bcdd-dbc5-40a3-9a50-dd8ba65cfa91" Name="hq-vbr1.democenter.int" Type="BackupServerReference" Rel="Up"/>
    <Link Href="http://hq-vbrem1.democenter.int:9399/api/hierarchyRoots/93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd" Name="vcsa.democenter.int" Type="HierarchyRootReference" Rel="Alternate"/>
    <Link Href="http://hq-vbrem1.democenter.int:9399/api/managedServers/93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd?format=Entity" Name="vcsa.democenter.int" Type="ManagedServer" Rel="Related"/>
  </Links>
  <HierarchyRootId>93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd</HierarchyRootId>
  <UniqueId>FFB4D8B6-CEC0-4DF8-87D5-82D931ED6FBD</UniqueId>
  <HostType>VC</HostType>
</HierarchyRoot>

The required reference for further use is the UID “urn:veeam:HierarchyRoot:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd” corresponding to the Veeam managed vCenter server where the VM should reside.

Note: It could have been more simple to directly work on the ManagedServer UID and directly change the resource type from “ManagedServer” to “HierarchyRoot”. The complex method was chosen for demonstration purpose.

Building a lookup to retrieve the virtual machine ID

<?xml version="1.0" encoding="UTF-8"?>
<HierarchyItems xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <HierarchyItem Type="HierarchyItem">
    <ObjectRef>urn:VMware:Vm:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd.vm-48911</ObjectRef>
    <ObjectType>Vm</ObjectType>
    <ObjectName>demo-win1</ObjectName>
  </HierarchyItem>
</HierarchyItems>

The UID here is given by the “ObjectRef” property: “urn:VMware:Vm:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd.vm-48911”. As you can see, the UID of the VM comprises the UID of the management server appended with the Mo-Ref of the VM. This is useful if you want to automatically build a Veeam VM reference, knowing its management server and Mo-Ref. This “manual” type construction of references can be used for automation purpose.

Building a query to retrieve the Job ID

Knowing the Name of the job where the VM should be added (“Test REST”) we can request the query service to get its ID:

<?xml version="1.0" encoding="UTF-8"?>
<QueryResult xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Refs>
    <Ref UID="urn:veeam:Job:455c0799-ede5-4ade-a7b2-02d2d0fac3de" Name="Test REST" Href="http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de" Type="JobReference">
      <Links>
        <Link Href="http://hq-vbrem1.democenter.int:9399/api/backupServers/d7b8bcdd-dbc5-40a3-9a50-dd8ba65cfa91" Name="hq-vbr1.democenter.int" Type="BackupServerReference" Rel="Up"/>
        <Link Href="http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de?format=Entity" Name="Test REST" Type="Job" Rel="Alternate"/>
        <Link Href="http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de/backupSessions" Type="BackupJobSessionReferenceList" Rel="Down"/>
      </Links>
    </Ref>
  </Refs>
  <PagingInfo PageNum="1" PageSize="100" PagesCount="1">
    <Links>
      <Link Href="http://hq-vbrem1.democenter.int:9399/api/query?type=job&filter=(Name%3d%3d%22Test+REST%22)&pageSize=100&page=1" Rel="First"/>
      <Link Href="http://hq-vbrem1.democenter.int:9399/api/query?type=job&filter=(Name%3d%3d%22Test+REST%22)&pageSize=100&page=1" Rel="Last"/>
    </Links>
  </PagingInfo>
</QueryResult>

Note: To access the resource (not the resource representation) and get more details, you shall follow the “Alternate” related object, which type is “Job” and not “JobReference”.

Adding the VM to the job

As stated by the “Min/Max” column, the only mandatory parameters to add in the request body are the container reference (a VM in our example) and name “HierarchyObjRef” and “HierarchyObjName”.

All other guest related parameters are described in the documentation. Specific credentials for inguest processing are described by the resource “/backupServers/{ID}/credentials”.

  • Order

  • GuestProcessingOptions

    • VssSnapshotOptions

    • WindowsGuestFSIndexingOptions

    • LinuxGuestFSIndexingOptions

    • SQLBackupOptions

    • WindowsCredentialsId

    • LinuxCredentialsId

    • FSFileExcludeOptions

    • OracleBackupOptions

We will then form a HTTP phrase: Type: POST

Header: (automatically handled by the client since cookies are in use) :

Cookie: X-RestSvcSessionId=Session_ID

Body:

<?xml version="1.0" encoding="UTF-8"?>
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <HierarchyObjRef>urn:VMware:Vm:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd.vm-48911</HierarchyObjRef>
    <HierarchyObjName>demo-win1</HierarchyObjName>
</CreateObjectInJobSpec>

To access the POST request from the Veeam WEB client, open the resource view of the job ID 455c0799-ede5-4ade-a7b2-02d2d0fac3de and follow the proposed link leading to add a VM in the job (Type=”ObjectInJob”, Rel=”Create”).

This will automatically form the HTTP request :

From there, the body can be modified to indicate proper VM reference:

<?xml version="1.0" encoding="utf-8"?>
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <HierarchyObjRef>urn:VMware:Vm:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd.vm-48911</HierarchyObjRef>
    <HierarchyObjName>demo-win1</HierarchyObjName>
</CreateObjectInJobSpec>

Upon completion, a return code 200 should be sent by the server, pointing to the corresponding task.

To verify if the added VM is in the job, we can send a quuery using the “ObjectInJob” type as described in the available querying type (refer to user guide “Query Syntax” section for more informations). The possible filter parameters are described in the “(GET) /jobs/{ID}/includes/{ID}” section of the reference guide.

<?xml version="1.0" encoding="UTF-8"?>
<QueryResult xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Resources>
    <sInObjectJob>
      <ObjectInJob Href="http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de/includes/8242bd6d-1aaf-41d7-9a11-e51fad56318f" Type="ObjectInJob">
        <Links>
          <Link Href="http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de/includes/8242bd6d-1aaf-41d7-9a11-e51fad56318f" Rel="Delete"/>
          <Link Href="http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de?format=Entity" Name="Test REST" Type="Job" Rel="Up"/>
        </Links>
        <ObjectInJobId>8242bd6d-1aaf-41d7-9a11-e51fad56318f</ObjectInJobId>
        <HierarchyObjRef>urn:VMware:Vm:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd.vm-48911</HierarchyObjRef>
        <Name>demo-win1</Name>
        <DisplayName>demo-win1</DisplayName>
        <Order>1</Order>
        <GuestProcessingOptions>
          <VssSnapshotOptions>
            <VssSnapshotMode>Disabled</VssSnapshotMode>
            <IsCopyOnly>false</IsCopyOnly>
          </VssSnapshotOptions>
          <WindowsGuestFSIndexingOptions>
            <FileSystemIndexingMode>Disabled</FileSystemIndexingMode>
            <IncludedIndexingFolders/>
            <ExcludedIndexingFolders/>
          </WindowsGuestFSIndexingOptions>
          <LinuxGuestFSIndexingOptions>
            <FileSystemIndexingMode>Disabled</FileSystemIndexingMode>
            <IncludedIndexingFolders/>
            <ExcludedIndexingFolders/>
          </LinuxGuestFSIndexingOptions>
          <SqlBackupOptions>
            <TransactionLogsProcessing>OnlyOnSuccessJob</TransactionLogsProcessing>
            <BackupLogsFrequencyMin>15</BackupLogsFrequencyMin>
            <UseDbBackupRetention>true</UseDbBackupRetention>
            <RetainDays>15</RetainDays>
          </SqlBackupOptions>
          <WindowsCredentialsId>00000000-0000-0000-0000-000000000000</WindowsCredentialsId>
          <LinuxCredentialsId>00000000-0000-0000-0000-000000000000</LinuxCredentialsId>
        </GuestProcessingOptions>
      </ObjectInJob>
    </sInObjectJob>
  </Resources>
  <PagingInfo PageNum="1" PageSize="100" PagesCount="1">
    <Links>
      <Link Href="http://hq-vbrem1.democenter.int:9399/api/query?type=ObjectInJob&filter=(JobName%3d%3d%22Test+REST%22%3bName%3d%3d%22demo-win1%22)&pageSize=100&page=1" Rel="First"/>
      <Link Href="http://hq-vbrem1.democenter.int:9399/api/query?type=ObjectInJob&filter=(JobName%3d%3d%22Test+REST%22%3bName%3d%3d%22demo-win1%22)&pageSize=100&page=1" Rel="Last"/>
    </Links>
  </PagingInfo>
</QueryResult>

Closing the connection

The final step is to close the connection. Using the VEEAM REST client, closing the client will close the connection. Using any other client, a DELETE should be sent to the session resource representation (leaving the body empty, as the session is referenced to in the URL as a resource).

The best starting point to get in touch with the Veeam PowerShell plugin is to read the Veeam PowerShell User Guide > .

You can find help for the scripts in the section. If you need some examples, refer to the following thread:

From the client browser, connect to the URL and enter credentials as requested. Then, follow the latest version URL to get the list of all accessible resources types.

Refering to the REST API guide we can gather necessary informations to build a query.

The lookup service necessitates a “HierarchyRoot” resource type in the urn, which is an alternate representation of the “ManagedServer”. We then must send a GET to the managed server resource representation: and find the “Alternate” representation of type “HierarchyRoot” in the proposed links.

Knowing the UID of the “Host” (vCenter), and the name of the guest we want to add to a job, we can build the lookup URL using the name of the VM as a selection criteria. The rules to build the lookup request are detailed in the REST API guide : .

)

The ID is given by the last part of the Ref UID : “urn:veeam:Job:455c0799-ede5-4ade-a7b2-02d2d0fac3de”. The URL to access the job resource representation is directly given by the link pointing to the “JobReference” type:

Knowing the “Jobs” resource representation structure, the resource to be called to add the VM to the job is "/jobs/{ID}/includes" with a POST verb. In case of any doubt about the resource to call, the REST reference guide offers a precise representation of the resource tree:

URL:

REST”;Name==”demo-win1”)

Link to Help Center
Link to Help Center
https://www.veeam.com/blog/veeam-backup-free-edition-now-with-powershell.html
Veeam Help Center - PowerShell Reference
Veeam Community Forums - PowerShell
Getting Started and Code Examples
Veeam Help Center - RESTful API Reference
Veeam Community Forums
Veeam Help Center - Beginner Example
http://EM:9399/web/#/api/
http://EM:9399/web/#/api/sessionMngr/?v=latest
https://helpcenter.veeam.com/docs/backup/rest/get_managedservers_id.html?ver=95
http://EM:9399/web/#/api/query?type=ManagedServer&filter=(ManagedServerType==VC;Name==”vcsa.democenter.int
http://EM:9399/web/#/api/managedServers/25fb843d-92a3-45d4-836c-0531afe4df9b?format=Entity
http://hq-vbrem1.democenter.int:9399/api/hierarchyRoots/93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd?format=Entity
https://helpcenter.veeam.com/docs/backup/rest/lookup_query.html?ver=95#params
http://hq-vbrem1.democenter.int:9399/web/#/api/lookup?host=urn:veeam:HierarchyRoot:93fe5565-0ae7-4574-abb5-0f4ea8c5e9bd&name=demo-win1&type=Vm
http://hq-vbrem1.democenter.int:9399/web/#/api/query?type=job&filter=(Name==%22Test REST%22
http://hq-vbrem1.democenter.int:9399/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de
https://helpcenter.veeam.com/docs/backup/rest/post_jobs_id_includes.html?ver=95
http://hq-vbrem1.democenter.int:9399/web/#/api/jobs/455c0799-ede5-4ade-a7b2-02d2d0fac3de/includes
http://hq-vbrem1.democenter.int:9399/web/#/api/query?type=ObjectInJob&filter=(JobName==”Test