Skip to main content


Veeam Logo

Veeam Backup & Replication Python API Wrapper

Python package for interacting with the Veeam Backup & Replication REST API

This project is an independent, open source Python client for the Veeam Backup & Replication REST API. It is not affiliated with, endorsed by, or sponsored by Veeam Software.

Supported Versions

VBR Version API Version Supported
13.1.0.411 1.3-rev2
13.0.1.180 1.3-rev1
13.0.0.4967 1.3-rev0
12.3.1.1139 1.2-rev1
< 12.3.1.1139 < 1.2-rev1

How to support new API versions

  1. Download the OpenAPI schema into openapi_schemas
  2. Install the openapi-python-client package
  3. Run python fix_openapi_yaml.py .\openapi_schemas\vbr_rest_{version}.json .\openapi_schemas\vbr_rest_{version}_fixed.json
  4. Run openapi-python-client generate --path ".\openapi_schemas\vbr_rest_{version}_fixed.json" --output-path ".\veeam_br" --overwrite
  5. Fix any warnings/errors
  6. Rename the folder to match the API version (i.e., v1.3-rev1)
  7. Add the version mapping to versions.py
  8. Write pytest tests
  9. If an older API has been deprecated, delete its folder, json, and version.py entry, then update the supported versions section of the readme

Install

From PyPi

pip install veeam-br

From Source

Clone the repository and install dependencies:

git clone https://github.com/Cenvora/veeam-br.git
cd veeam-br
pip install -e .

Usage

Recommended Usage (Smart Client)

The VeeamClient handles:

  • API version routing
  • Authentication
  • Token refresh
  • x-api-version header injection so package API version matches header values
  • Async calls
  • Operation discovery

Each packaged version can be called independently through separate imports, but this is the recommended way to use this library.

Create a client and connect

import asyncio
from veeam_br.client import VeeamClient

async def main():
    vc = VeeamClient(
        host="https://vbr.example.com:9419",
        username="administrator",
        password="SuperSecretPassword",
        api_version="1.3-rev1",
        verify_ssl=False,
    )

    await vc.connect()

    # use the client...

    await vc.close()

asyncio.run(main())

Detect the API version a server serves

The REST API has no endpoint that reports its supported versions, and Veeam's guidance is that the caller picks one. What a server does expose is a Swagger document per version it serves, so detect_api_version probes those and returns the newest version that both the server serves and this library can speak:

import asyncio
from veeam_br.client import VeeamClient
from veeam_br.discovery import detect_api_version

async def main():
    base_url = "https://vbr.example.com:9419"

    api_version = await detect_api_version(base_url, verify_ssl=False)
    if api_version is None:
        # Swagger may be unreachable, disabled or gated — choose your own default
        api_version = "1.3-rev1"

    vc = VeeamClient(
        host=base_url,
        username="administrator",
        password="SuperSecretPassword",
        api_version=api_version,
        verify_ssl=False,
    )
    await vc.connect()

asyncio.run(main())

Detection needs no credentials, so it can run before you have any. Probes are concurrent, so it costs roughly one round trip regardless of how many versions this library supports.

Resolve it once and store the result rather than detecting on every start: a server upgrade would otherwise silently move you onto a newer revision, and revisions rename enum values and add required fields.

Call an API endpoint (async)

repos = await vc.call(
    vc.api("repositories").get_all_repositories
)

Filter certain object types

Some objects, such as SmartObjectS3, use polymorphic subtypes with circular inheritance. These tend to not play well with package creation tools, so as part of the import process into this project, those relationships are broken. Where a repository would normally have a bucket object with immutability information inside, this breakage instead causes bucket to always be UNSET and instead populates the data into additional_properties. For example:

from veeam_br.v1_3_rev1.models.e_repository_type import ERepositoryType

smart_s3 = [
    r for r in repos.data
    if r.type_ == ERepositoryType.SMARTOBJECTS3
]

So to access bucket & immutability data:

for repo in smart_s3:
    bucket = repo.additional_properties.get("bucket", {})
    immutability = bucket.get("immutability", {})

    print({
        "name": repo.name,
        "bucket": bucket.get("bucketName"),
        "days": immutability.get("daysCount"),
        "enabled": immutability.get("isEnabled"),
    })

Until openapi-python-client figures out and implements a way around this or Veeam rewrites their OpenAPI schemas to not use circular references/inheritance, this is a known limitation.

Call any endpoint

Operations map directly to the OpenAPI layout:

api/
└── repositories/
    └── get_all_repositories.py

Call it like this:

await vc.call(
    vc.api("repositories").get_all_repositories
)

Or explicity:

await vc.call(
    vc.api("repositories.get_all_repositories")
)

Names that shadow Python builtins

openapi-python-client appends a trailing underscore to any generated identifier that would shadow a Python builtin or keyword. The license tag is the one that shows up in practice, so its namespace is license_:

await vc.call(
    vc.api("license_").get_installed_license
)

This is the same rule behind the type_ attribute used in the filtering example above.

Pagination example

result = await vc.call(
    vc.api("repositories").get_all_repositories,
    limit=50,
    skip=0,
)

Close the client

await vc.close()

Contributing

Contributions are welcome! To contribute:

  • Fork the repository
  • Create a feature branch
  • Make your changes and add tests
  • Submit a pull request with a clear description

Please follow PEP8 style and include docstrings for new functions/classes.

🤝 Core Contributors

This project is made possible thanks to the efforts of our core contributors:

We’re grateful for their continued support and contributions.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

veeam_br-0.4.0.tar.gz (4.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

veeam_br-0.4.0-py3-none-any.whl (8.6 MB view details)

Uploaded Python 3

File details

Details for the file veeam_br-0.4.0.tar.gz.

File metadata

  • Download URL: veeam_br-0.4.0.tar.gz
  • Upload date:
  • Size: 4.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for veeam_br-0.4.0.tar.gz
Algorithm Hash digest
SHA256 547124e81f668a5ee74998c6b169b08efdaebf8182e2e9eb7f04a715879dcfbc
MD5 b47067e43575398d83f689433c098aa8
BLAKE2b-256 02e4fe06994663ca4de3b3a322a209abb9d1c3339e96cb7530c2bb7f236d9adf

See more details on using hashes here.

Provenance

The following attestation bundles were made for veeam_br-0.4.0.tar.gz:

Publisher: publish-on-release.yml on Cenvora/veeam-br

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file veeam_br-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: veeam_br-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for veeam_br-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3765d2bd96448ff8d4077128e954d4c1620400e2da159e702ec47961c029f59
MD5 8a26c387c42f9a003a49514ae019d342
BLAKE2b-256 ff6aec6a1cf11608074fb28c365c5d78bc50d8392e8d26602009611684cf652b

See more details on using hashes here.

Provenance

The following attestation bundles were made for veeam_br-0.4.0-py3-none-any.whl:

Publisher: publish-on-release.yml on Cenvora/veeam-br

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page